Forum Discussion
Combining Multiple DAX Measures - how to do it?
Hi - I have a couple of measures that I compare against each other to get another measure - I'd like to be able to put all 3 of them into one longer DAX measure, is that possible?? Is there a more elegant way of doing everything in one? I have:
WEEK 31 Total Products =
CALCULATE(
COUNTROWS ('Combined_GPI'),
FILTER('Combined_GPI','Combined_GPI'[Week] = 31)
)
and
WEEK 31 Out of Stock =
CALCULATE(
COUNTROWS ('Combined_GPI'),
FILTER('Combined_GPI','Combined_GPI'[OOS] = 1),
FILTER('Combined_GPI','Combined_GPI'[Week] = 31)
)
which I then use to get
WEEK 31 AVAILABILITY =
1 - DIVIDE(('Combined_GPI'[WEEK 31 Out of Stock]), ('Combined_GPI'[WEEK 31 Total Products]))
Any help greatly appreciated!
Dan 🙂
Anonymous Try:
WEEK 31 AVAILABILITY = VAR __WEEK31TotalProducts = CALCULATE( COUNTROWS ('Combined_GPI'), FILTER('Combined_GPI','Combined_GPI'[Week] = 31) ) VAR __WEEK31OutofStock = CALCULATE( COUNTROWS ('Combined_GPI'), FILTER('Combined_GPI','Combined_GPI'[OOS] = 1), FILTER('Combined_GPI','Combined_GPI'[Week] = 31) ) RETURN 1 - DIVIDE(('Combined_GPI'[__WEEK31OutofStock]), ('Combined_GPI'[__WEEK31TotalProducts]))
3 Replies
- goncalogeraldes
Super User
Hi there! In this case you can make use of variables inside of a single measure. For example, in your case ot could be:
WEEK 31 AVAILABILITY = var WEEK_31_Total_Products = CALCULATE( COUNTROWS ('Combined_GPI'), FILTER('Combined_GPI','Combined_GPI'[Week] = 31) ) var WEEK_31_Out_of_Stock = CALCULATE( COUNTROWS ('Combined_GPI'), FILTER('Combined_GPI','Combined_GPI'[OOS] = 1), FILTER('Combined_GPI','Combined_GPI'[Week] = 31) ) return CALCULATE( 1 - DIVIDE(WEEK_31_Out_of_Stock, WEEK_31_Total_Products) )Hope this solves your problem! If you need additional help please tag me in your reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️ or give it a kudoe 👍
Thanks!
Best regards,
Gonçalo Geraldes - Greg_Deckler
Community Champion
Anonymous Try:
WEEK 31 AVAILABILITY = VAR __WEEK31TotalProducts = CALCULATE( COUNTROWS ('Combined_GPI'), FILTER('Combined_GPI','Combined_GPI'[Week] = 31) ) VAR __WEEK31OutofStock = CALCULATE( COUNTROWS ('Combined_GPI'), FILTER('Combined_GPI','Combined_GPI'[OOS] = 1), FILTER('Combined_GPI','Combined_GPI'[Week] = 31) ) RETURN 1 - DIVIDE(('Combined_GPI'[__WEEK31OutofStock]), ('Combined_GPI'[__WEEK31TotalProducts]))- AnonymousNot applicable
Thanks Greg_Deckler - thats super helpful! I'll do some learning on Variables 🙂