Forum Discussion
DAX : SUM is wrong in matrix
Hi everyone,
I need your help for a calculation.
I make this :
This measure works fine when it's display in a card.
But in my matrix (by Etablissement[Name]) , totals are wrong for VAR _SALES (all values).
When the slicer is not filtered, total show VAR _SALES_NOPROD results.
pls try this
6 Replies
- AnonymousNot applicable
Hi marakud ,
It seems like you are trying to calculate sales with a filter on a specific value. However, the total is not showing the correct value in the matrix. One possible reason for this could be that the filter context is not being applied correctly. You may want to try using the ALL function to remove the filter context from the calculation. Here is an example of how you could modify your measure:
Sales = VAR _SALES = CALCULATE ( SUM ( 'Ca Réalisé'[Sales] ) ) VAR _SALES_NOPROD = CALCULATE ( SUM ( 'Ca Réalisé'[Sales] ), T_DIM_PLAN2_NIV3[P2_NIV3_LIBELLE] <> "PROD SEULEMENT" ) RETURN IF ( ISFILTERED ( Etablissement[Name] ), CALCULATE(_SALES_NOPROD, ALL(Etablissement[Name])), _SALES )This should remove the filter context from the calculation and give you the correct total in the matrix.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- marakudFrequent Visitor
I have observed that the issue stems from the ISFILTERED function, which considers the subcategories of the hierarchy as filtered rows. As a result, it always performs the first calculation based on the condition.
- marakudFrequent Visitor
how to solve this ?
- marakudFrequent Visitor
hi ! thanks for your answer.
I tried your solution but no changes.
here the demo file : https://we.tl/t-dyunwmyxrAthanks again.
Best
- marakudFrequent Visitor
for more information :
When my slicer is on, i need the calculation to be filter.
And when it's off, i need all values selected.
But when slicer is inactive , "PROD SEULEMENT" value is not in my SUM.Best
- Ahmedx
Super User
pls try this