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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
rhaddad87
Helper I
Helper I

Combine 3 measures into one DAX expression?

Hi there!

I currently make a new measure every time I need to alter or calculate a result to display in my tracking dashboard.  Can you help me combine all of these to get the intended result?

 

First, I calculate the date to get the date that the last MX was completed:

 

Last 200hr MX Date = CALCULATE(MAX(xxData[Date]),CONTAINSSTRING(xxData[Comments], "MX"))

 

 

Calculate the number of hours since that date:

 

Hours since 200hr MX = 
VAR LastMX = [Last 200hr MX Date]
RETURN
    CALCULATE(SUM(xxData[Flight Hours]),dimDate[Date]> LastMX)

 

 

Divide the number of hours by 18, remove any decimals, and add " flights" to the end:

 

final200 = 

VAR c200 = (200-[Hours since 200hr MX])/18
        RETURN
        TRUNC(c200) & " flights"

 

 

I lack the coding experience to string these all together in one function.  Can anyone help?  Also need to make it so it does not return a negative number, only 0 as the lowest possible result.

 

Thank you! 

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @rhaddad87 

 

Try this:

 

 

final200 =
VAR _LastMX =
    CALCULATE ( MAX ( xxData[Date] ), CONTAINSSTRING ( xxData[Comments], "MX" ) )
VAR _HS200 =
    CALCULATE ( SUM ( xxData[Flight Hours] ), dimDate[Date] > _LastMX )
VAR _C200 = ( 200 - _HS200 )/ 18
RETURN
    TRUNC ( _C200 ) & " flights"

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

View solution in original post

2 REPLIES 2
rhaddad87
Helper I
Helper I

@VahidDM Vahid this works perfetly.  Thank you so much for your help!  Are you able to suggest any courses or specific topics that I should study to improve my understanding of DAX expressions and how to combine them?

VahidDM
Super User
Super User

Hi @rhaddad87 

 

Try this:

 

 

final200 =
VAR _LastMX =
    CALCULATE ( MAX ( xxData[Date] ), CONTAINSSTRING ( xxData[Comments], "MX" ) )
VAR _HS200 =
    CALCULATE ( SUM ( xxData[Flight Hours] ), dimDate[Date] > _LastMX )
VAR _C200 = ( 200 - _HS200 )/ 18
RETURN
    TRUNC ( _C200 ) & " flights"

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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