Forum Discussion
Help with matrix DAX
Hello, I have the following slicers set up in my dashboard:
- Date
- Fruit Category
- Fruit Name
- Fruit Color
- Fruit Sweetness Level
And I have the following formula that gives me the dynamic MoM% calculation when any two dates in my date slicer is selected:
My issue is, everytime more than 2 slicers are selected, my calculation goes blank. I'm getting the right numbers, however for some reason my calculation won't work when more than 2 slicers are selected. For example, if I chose a two values in the Date slicer, then I chose a value in the Fruit Category slicer, I get the correct result. But if I then try to also choose a value in the Fruit Name slicer, the result shows "N/A".
Could you please help me figure this out?
Anonymous Try using
DAX
FruitPurchases =
VAR EndMonthYear =
MAXX ( ALLSELECTED ( 'Table_Month'[Number] ), 'Table_Month'[Number] )
VAR StartMonthYear =
MAXX ( ALLSELECTED ( 'Table_Month'[Number] ), 'Table_Month'[Number] ) - 1
VAR StartSpend =
CALCULATE ( [sumfruitprices], REMOVEFILTERS('Table_Month'), 'Table_Month'[Number] = StartMonthYear )
VAR EndSpend =
CALCULATE ( [sumfruitprices], REMOVEFILTERS('Table_Month'), 'Table_Month'[Number] = EndMonthYear )
RETURN
IF (
NOT ISBLANK ( StartSpend ) && NOT ISBLANK ( EndSpend ),
DIVIDE ( EndSpend - StartSpend, StartSpend),
"N/A"
)
3 Replies
- bhanu_gautamSuper User
Anonymous Try using
DAX
FruitPurchases =
VAR EndMonthYear =
MAXX ( ALLSELECTED ( 'Table_Month'[Number] ), 'Table_Month'[Number] )
VAR StartMonthYear =
MAXX ( ALLSELECTED ( 'Table_Month'[Number] ), 'Table_Month'[Number] ) - 1
VAR StartSpend =
CALCULATE ( [sumfruitprices], REMOVEFILTERS('Table_Month'), 'Table_Month'[Number] = StartMonthYear )
VAR EndSpend =
CALCULATE ( [sumfruitprices], REMOVEFILTERS('Table_Month'), 'Table_Month'[Number] = EndMonthYear )
RETURN
IF (
NOT ISBLANK ( StartSpend ) && NOT ISBLANK ( EndSpend ),
DIVIDE ( EndSpend - StartSpend, StartSpend),
"N/A"
)- AnonymousNot applicable
This worked like a charm. Thank you so much
- TomMartensSuper User
Hey Anonymous ,
Please provide a screenshot of your semantic model.
I assume that all your "Fruit ..." slicers are coming from the same table; I'm not sure if it's a dedicated "fruit" table. Hence, I'm asking for a screenshot of your semantic model.Regards,
Tom