March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I am new to DAX and have absolute minimal idea about formulas. Could someone please help me construct a measure that computes for the difference (amount) between the earliest of status 1 and the latest for status 2 filtered by ticket? In the below screenshot, for example, it should be:
Ticket 0001 > -120 (earliest of status FINE_OFFSET) + 50 (latest of status FINE) = 70 (correct answer for Ticket 0001)
Ticket 0002 > 0 + 150 = 150
Thank you in advance!
Solved! Go to Solution.
Hi @e_vera ,
We can create a measure to meet your requirement:
Measure =
VAR FirstTimeForStatus1 =
CALCULATE ( MIN ( 'Table'[Date/Time] ), 'Table'[Status] = "FINE_OFFSET" )
VAR LastTimeForStatus2 =
CALCULATE ( MAX ( 'Table'[Date/Time] ), 'Table'[Status] = "FINE" )
RETURN
CALCULATE (
SUM ( 'Table'[Amount] ),
'Table'[Status] = "FINE_OFFSET",
'Table'[Date/Time] = FirstTimeForStatus1
)
+ CALCULATE (
SUM ( 'Table'[Amount] ),
'Table'[Status] = "FINE",
'Table'[Date/Time] = LastTimeForStatus2
)
Best regards,
@e_vera try this measure
Measure 1 =
VAR __fineOffset =
CALCULATE (
MAX ( Fine[Amount] ),
TOPN( 1, FILTER( ALL ( Fine ), Fine[Ticket] = MAX ( Fine[Ticket] ) && Fine[Flag] = "Fine_Offset" ), Fine[Date/Time], ASC )
)
VAR __fine =
CALCULATE (
MAX ( Fine[Amount] ),
TOPN( 1, FILTER( ALL ( Fine ), Fine[Ticket] = MAX ( Fine[Ticket] ) && Fine[Flag] = "Fine" ), Fine[Date/Time], DESC )
)
RETURN
__fineOffset + __fine
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
hi parry2k,
Thank you so much for your suggestion. Unfortunately, the formula is not returning any value. I've tried removing the second var as well (keeping only fineOffset) but it's still blank.
Hi @e_vera ,
We can create a measure to meet your requirement:
Measure =
VAR FirstTimeForStatus1 =
CALCULATE ( MIN ( 'Table'[Date/Time] ), 'Table'[Status] = "FINE_OFFSET" )
VAR LastTimeForStatus2 =
CALCULATE ( MAX ( 'Table'[Date/Time] ), 'Table'[Status] = "FINE" )
RETURN
CALCULATE (
SUM ( 'Table'[Amount] ),
'Table'[Status] = "FINE_OFFSET",
'Table'[Date/Time] = FirstTimeForStatus1
)
+ CALCULATE (
SUM ( 'Table'[Amount] ),
'Table'[Status] = "FINE",
'Table'[Date/Time] = LastTimeForStatus2
)
Best regards,
Thank you so much for this, it works now!
@e_vera how you are using it? Did you put Ticket column in the table visual and this measure? Share the screen shot. Do you have any filter or relationship that has impact. Provide more details.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |