Forum Discussion
DAX
- 1 year ago
Hi Cyriackpazhe,
Thank you for reaching out to the Microsoft fabric community forum. Thank you some_bih, for your inputs on this issue.
Thank you for bringing this to my attention. Upon reviewing your DAX measures, I noticed the inconsistency in average quarterly and monthly sales across different periods, even with the ALL() function applied.
This occurs because ALL('Calendar'[Quarter]) or ALL('Calendar'[Month]) only removes the filter for that specific column. However, in a matrix visual with a hierarchy (such as Year > Quarter or Year > Month), the row-level filters from the visual still affect the context, resulting in varying outcomes for each row.
To ensure the calculation is performed at the year level and the same value is displayed across quarters or months in the matrix, you can use the following DAX measures with ALLEXCEPT, which retains only the Year filter:
Quarterly Average:
DAX CopyEdit Quarterly Average = CALCULATE ( AVERAGEX ( VALUES ( 'Calendar'[Quarter] ), [Total Sales] ), ALLEXCEPT ( 'Calendar', 'Calendar'[Year] ) )Monthly Average:
DAX CopyEdit Monthly Average = CALCULATE ( AVERAGEX ( VALUES ( 'Calendar'[Month] ), [Total Sales] ), ALLEXCEPT ( 'Calendar', 'Calendar'[Year] ) )ALLEXCEPT clears all filters from the Calendar table except for Year, so the average is always calculated at the year level just as intended. This approach avoids row context interference from the visual (like month or quarter rows).
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
Hi Cyriackpazhe,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.
Hi Cyriackpazhe,
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.