Hi all,
I'm using Excel 365 (2016). I have a parameter table (paramTbl) which I'm showing to the user as a slicer, next to the Power Pivot table. Based on user's selection, a certain measure should (or should not) apply a filter to the order's table.
You can see from the Measure above, I use an IF statement to execute one of the two CALCULATE functions, based on the user's selection in the paramTbl. The only difference between these two CALCULATE is an additional filter at the end (SeasonPart=YTD).
There are some more, complex filters, however those are all the same in both CALCULATE versions. In order to avoid code duplication, I would like to reduce one CALCULATE and remain only one version. How can apply the last filter (SeasonPart=YTD) with correct syntax?
Thanks for your help
Regards
Janosh
I'm using Excel 365 (2016). I have a parameter table (paramTbl) which I'm showing to the user as a slicer, next to the Power Pivot table. Based on user's selection, a certain measure should (or should not) apply a filter to the order's table.
Code:
Measure :=
[COLOR=#0070FF]IF[/COLOR][COLOR=#969696] ([/COLOR]
[COLOR=#0070FF]FIRSTNONBLANK[/COLOR][COLOR=#969696] ([/COLOR] paramTbl[param1]; paramTbl[param1] [COLOR=#969696])[/COLOR] = [COLOR=#D93124]"YTD"[/COLOR];
[COLOR=#0070FF]CALCULATE[/COLOR][COLOR=#969696] ([/COLOR] [COLOR=#0070FF]SUM[/COLOR][COLOR=#969696] ([/COLOR] Orders[Amount] [COLOR=#969696])[/COLOR]; /*some other complex filter*/ ; Orders[SeasonPart] = [COLOR=#D93124]"YTD"[/COLOR] [COLOR=#969696])[/COLOR];
[COLOR=#0070FF]CALCULATE[/COLOR][COLOR=#969696] ([/COLOR] [COLOR=#0070FF]SUM[/COLOR][COLOR=#969696] ([/COLOR] Orders[Amount] [COLOR=#969696])[/COLOR]; /*some other complex filter*/ [COLOR=#969696])[/COLOR]
[COLOR=#969696])[/COLOR]
You can see from the Measure above, I use an IF statement to execute one of the two CALCULATE functions, based on the user's selection in the paramTbl. The only difference between these two CALCULATE is an additional filter at the end (SeasonPart=YTD).
There are some more, complex filters, however those are all the same in both CALCULATE versions. In order to avoid code duplication, I would like to reduce one CALCULATE and remain only one version. How can apply the last filter (SeasonPart=YTD) with correct syntax?
Thanks for your help
Regards
Janosh