Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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 🙂
Solved! Go to Solution.
@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]))
@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]))
Thanks @Greg_Deckler - thats super helpful! I'll do some learning on Variables 🙂
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |