Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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!
Solved! Go to Solution.
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/
@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?
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/