Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

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 🙂

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
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]))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
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]))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks @Greg_Deckler  - thats super helpful! I'll do some learning on Variables 🙂

goncalogeraldes
Super User
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

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors