Forum Discussion
var return with Slicers.
- 6 years ago
Right but you are still using VAR's and CALCULATE weird. Try this:
Quantity sold = CALCULATE( SUMX( sales, sales[quantity]), DATESYTD( date[date] ), FILTER( product, product[code] = "A") )The other option would be to take your 2 VAR's and turn them into their own measures, then what you are doing with the CALCULATE would make more sense.
I've never seen a FILTER clause used as a variable and then passed into a CALCULATE function. That's weird and I'm kind of surprised it works. Try taking your FILTER clause for ProductFilter and replace ProductFilter in your RETURN statement with the actual FILTER clause and see if that works.
- Young_G_Han6 years ago
Helper III
Thank you for your advice.
But it is not working....
After change the dax formula as following, Change slicer for product[code] <> A presents values....
I must be 0 or empty...
Quantity sold =
var Quantity = SUMX( sales, sales[quantity])
var QuantityYTD = CALCULATE( Quantity, DATESYTD( date[date] ) )return
CALCULATE( QuantityYTD, FILTER( product, product[code] = "A"))- Greg_Deckler6 years ago
Community Champion
Right but you are still using VAR's and CALCULATE weird. Try this:
Quantity sold = CALCULATE( SUMX( sales, sales[quantity]), DATESYTD( date[date] ), FILTER( product, product[code] = "A") )The other option would be to take your 2 VAR's and turn them into their own measures, then what you are doing with the CALCULATE would make more sense.
- Young_G_Han6 years ago
Helper III
Yes. It is working.
Because I have many similar calculation, I tried to use var - return calculation.
I am not familiar with dax yet, I have tried.
Can you please advise me that any web page or helpful document that can help me to understand var - return calculation?