Forum Discussion
Slicer selection in dax calculation
Hi all,
Hoping someone could help me.
My report has a column which shows the calculation for values selected in slicer. For example- i have values A,B,C in slicer. if i select "A",column should display calculation for A, if b selected, column should show calculation for B
I went like this
VersionFilter=SELECTEDVALUE(Fact[Version])
Dax Measure=FY20 Budget Year Total Working = CALCULATE([TotalYTDNet],'FACT'[SCENARIO]="BUDGET",AsOfPeriodTable1[AS_OF_YEAR]=2020,AsOfPeriodTable1[TimePeriod]="Dec",'FACT'[VERSION]=[VersionFilter])
But, its throwing error as
A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.
Please help me to achieve functionality
Hi vamshik153,
You could refer to above suggestions, or you also could try below measure to see whether it work or not.
Dax Measure=FY20 Budget Year Total Working = if(min('FACT'[VERSION])=SELECTEDVALUE(Fact[Version]), CALCULATE([TotalYTDNet],'FACT'[SCENARIO]="BUDGET",AsOfPeriodTable1[AS_OF_YEAR]=2020,AsOfPeriodTable1[TimePeriod]="Dec"),0)Best Regards,
Zoe ZhiIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Try any of the one
FY20 Budget Year Total Working = CALCULATE([TotalYTDNet],AsOfPeriodTable1[AS_OF_YEAR]=2020 ,AsOfPeriodTable1[TimePeriod]="Dec",filter('FACT','FACT'[SCENARIO]="BUDGET",'FACT'[VERSION]=[VersionFilter])) FY20 Budget Year Total Working = CALCULATE([TotalYTDNet],filter(AsOfPeriodTable1,AsOfPeriodTable1[AS_OF_YEAR]=2020 ,AsOfPeriodTable1[TimePeriod]="Dec"),filter('FACT','FACT'[SCENARIO]="BUDGET",'FACT'[VERSION]=[VersionFilter]))Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601
3 Replies
- Gordonlilj
Solution Sage
Hi,
I'm guessing the 'FACT'[VERSION]=[VersionFilter] is the problem. Perhaps you could try creating a variable instead like the example below
FY20 Budget Year Total Working = VAR VersionFilterVAR = [VersionFilter] RETURN CALCULATE([TotalYTDNet],'FACT'[SCENARIO]="BUDGET",AsOfPeriodTable1[AS_OF_YEAR]=2020,AsOfPeriodTable1[TimePeriod]="Dec",'FACT'[VERSION]= VersionFilterVAR) - dax
Community Support
Hi vamshik153,
You could refer to above suggestions, or you also could try below measure to see whether it work or not.
Dax Measure=FY20 Budget Year Total Working = if(min('FACT'[VERSION])=SELECTEDVALUE(Fact[Version]), CALCULATE([TotalYTDNet],'FACT'[SCENARIO]="BUDGET",AsOfPeriodTable1[AS_OF_YEAR]=2020,AsOfPeriodTable1[TimePeriod]="Dec"),0)Best Regards,
Zoe ZhiIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- amitchandak
Super User
Try any of the one
FY20 Budget Year Total Working = CALCULATE([TotalYTDNet],AsOfPeriodTable1[AS_OF_YEAR]=2020 ,AsOfPeriodTable1[TimePeriod]="Dec",filter('FACT','FACT'[SCENARIO]="BUDGET",'FACT'[VERSION]=[VersionFilter])) FY20 Budget Year Total Working = CALCULATE([TotalYTDNet],filter(AsOfPeriodTable1,AsOfPeriodTable1[AS_OF_YEAR]=2020 ,AsOfPeriodTable1[TimePeriod]="Dec"),filter('FACT','FACT'[SCENARIO]="BUDGET",'FACT'[VERSION]=[VersionFilter]))Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601