Forum Discussion
Power BI - CY, PY Calculation - DAX
- 2 years ago
Yes, ALLSELCTED() allows items in the filter context (your page filters) pass through to the calculation.
More information (with examples) on ALLSELECTED() can be found here:
https://www.sqlbi.com/articles/the-definitive-guide-to-allselected/ALL(), REMOVEFILTERS(), and ALLSELECTED() are key modifiers for the filter context in BI, any time spent understanding them is well worth while.
Yes, ALLSELCTED() allows items in the filter context (your page filters) pass through to the calculation.
More information (with examples) on ALLSELECTED() can be found here:
https://www.sqlbi.com/articles/the-definitive-guide-to-allselected/
ALL(), REMOVEFILTERS(), and ALLSELECTED() are key modifiers for the filter context in BI, any time spent understanding them is well worth while.
Thank you for the link.
I created a measure and used ALLSELECTED() and it partially fixed the issue.
CY = CALCULATE(MAX('Table1'[Date]), ALLSELECTED())
I have created other measures which used the above measure, but in few cases I used AVGX/SUMX.
CY Sales = CALCULATE(SUM('Table1'[Sales]), FILTER('Table1', 'Table1'[Date] = [CY]))
In those measures, the value was not populating correctly and as mentioned in the link, it gave weird results.
So I deleted the main measure that has ALLSELECTED() and created a variable under other measures that needs that ALLSELECTED() and everything worked fine.
CY Sales =
VAR cy = CALCULATE(MAX('Table1'[Date]), ALLSELECTED())
RETURN
CALCULATE(SUM('Table1'[Sales]), FILTER('Table1', 'Table1'[Date] = cy))
The above is just a sample code and not actual code.
So I understood that ALLSELECTED() will not go well with SUMX/AVGX (X functions).