Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all,
I got strange situation with calculated measure and pie chart/bar chart. I have:
sales amount = IF(ISFILTERED(FACT_SALES[Date]) , SUM(FACT_SALES[QTY]), CALCULATE(SUM(FACT_SALES[QTY]),FILTER(FACT_SALES, FACT_SALES[Date]= max(FACT_SALES[Date]) ) ) )
When i choose one date in slicer, everything is working correctly. but when select nothing. the pie chart with SITEID in legend showing wrong value. however it's correct without siteid.
Did i miss something in my DAX expression?
Solved! Go to Solution.
Please refer to following screenshot, if it is your desired result. Please try with following DAX expression.
sales amount = VAR MaxDate = CALCULATE ( MAX ( FACT_SALES[Date] ), ALLSELECTED ( FACT_SALES[SITEID] ), ALLSELECTED ( FACT_SALES[Date] ) ) RETURN IF ( ISFILTERED ( FACT_SALES[Date] ), SUM ( FACT_SALES[QTY] ), CALCULATE ( SUM ( FACT_SALES[QTY] ), FILTER ( FACT_SALES, FACT_SALES[Date] = MaxDate ) ) )
Best Regards,
Herbert
Please refer to following screenshot, if it is your desired result. Please try with following DAX expression.
sales amount = VAR MaxDate = CALCULATE ( MAX ( FACT_SALES[Date] ), ALLSELECTED ( FACT_SALES[SITEID] ), ALLSELECTED ( FACT_SALES[Date] ) ) RETURN IF ( ISFILTERED ( FACT_SALES[Date] ), SUM ( FACT_SALES[QTY] ), CALCULATE ( SUM ( FACT_SALES[QTY] ), FILTER ( FACT_SALES, FACT_SALES[Date] = MaxDate ) ) )
Best Regards,
Herbert
Hi @v-haibl-msft,
Thanks for your response. Your suggestion is not my point, but I could refer your expr and realize that if i use variable, it will work for my expectation:
Not working expr:
m = IF(ISFILTERED(FACT_SALES[Ngày]) , SUM(FACT_SALES[QTY]), CALCULATE(SUM(FACT_SALES[QTY]),FILTER(all(FACT_SALES), FACT_SALES[Ngày]=CALCULATE( max(FACT_SALES[Ngày]),all(FACT_SALES) ) ) ) )
And working expr after refer your code:
sales amount = VAR MaxDate = CALCULATE ( MAX ( FACT_SALES[Ngày] ), ALL(FACT_SALES) ) RETURN IF ( ISFILTERED ( FACT_SALES[Ngày] ), SUM ( FACT_SALES[QTY] ), CALCULATE ( SUM ( FACT_SALES[QTY] ), FILTER ( FACT_SALES, FACT_SALES[Ngày] = MaxDate ) ) )
@v-haibl-msft: one more concern, is there any wrong with the old expression? (using all inside the filter method)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
97 | |
75 | |
65 | |
53 |
User | Count |
---|---|
144 | |
103 | |
98 | |
85 | |
64 |