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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
topazz11
Helper III
Helper III

DAX to pick up value

Hello, I would like to create a measure that returns the cost with conditions.

The conditions are 'highest Seq', 'Current', and 'Approved' per Item ID (Please see below pic)

Anyone know how to do this? Thank you

 

pickup.JPG

1 ACCEPTED SOLUTION
JarroVGIT
Resident Rockstar
Resident Rockstar

Well, interesting question! I've copied your dataset into PBI and got to work. This seems to work;

 

MaxSeqCurrentApproved = CALCULATE(SUM('Table'[Cost]), FILTER('Table', 'Table'[Seq] = CALCULATE(MAX('Table'[Seq]), FILTER('Table', 'Table'[CurrInd] = "Current" && 'Table'[Status] = "Approved"))))

 

Explaination:We take the sum of Cost -> although it is just one row

with a Filter on the table, -> here is the tricky part

where Seq = the Max seq with a filter -> this will work where the context is sliced by Item btw,

where CurrInd = Curent AND Status = Approved -> having the Seq with Current and Status set correctly is enough, we don't need a second filter on these fields.

 

Ain't pretty but it works in my test (which is a matrix with rows=ItemID (not summarized) and values=Measure) 🙂

 

Please mark as solution if this answers your question.

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Drag Item ID to the Row labels and write these 2 measures

Last sequence number = CALCULATE(LASTNONBLANK(Data[Seq],1),Data[Status]="Approved",Data[Curr Ind]="Current")
Costs = LOOKUPVALUE(Data[Cost],Data[Seq],[Last sequence number],Data[Status],"Approved",Data[Curr Ind],"Current")

I see no sense in showing Curr Ind and Status in the visual because they are the very conditions for our calculations.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
JarroVGIT
Resident Rockstar
Resident Rockstar

Well, interesting question! I've copied your dataset into PBI and got to work. This seems to work;

 

MaxSeqCurrentApproved = CALCULATE(SUM('Table'[Cost]), FILTER('Table', 'Table'[Seq] = CALCULATE(MAX('Table'[Seq]), FILTER('Table', 'Table'[CurrInd] = "Current" && 'Table'[Status] = "Approved"))))

 

Explaination:We take the sum of Cost -> although it is just one row

with a Filter on the table, -> here is the tricky part

where Seq = the Max seq with a filter -> this will work where the context is sliced by Item btw,

where CurrInd = Curent AND Status = Approved -> having the Seq with Current and Status set correctly is enough, we don't need a second filter on these fields.

 

Ain't pretty but it works in my test (which is a matrix with rows=ItemID (not summarized) and values=Measure) 🙂

 

Please mark as solution if this answers your question.

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




parry2k
Super User
Super User

@topazz11 or try this

 

Total Cost = 
VAR __seq = CALCULATE( MAX ( Pickup[Seq] ), ALLEXCEPT ( Pickup, Pickup[Item Id] ), Pickup[Curr Ind] = "Current", Pickup[Status] = "Approved" )
RETURN
CALCULATE ( SUM ( Pickup[Cost] ), Pickup[Seq] = __seq, Pickup[Curr Ind] = "Current", Pickup[Status] = "Approved"  )

 



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.

jdbuchanan71
Super User
Super User

Hello @topazz11 

I'm going to assume you want the returned costs to add up correctly so this measure is a SUMX.  It also returns a value for [Item ID] 42180 from your sample since that item ID has a line matches the criteria ("Current", "Approved" ).

Measure = 
SUMX ( VALUES ( 'Table'[Item ID] ),
    VAR _Seq = 
        CALCULATE ( 
            MAX ( 'Table'[Seq] )
            ,ALLEXCEPT ( 'Table', 'Table'[Item ID] )
            ,'Table'[Curr Ind] = "Current" 
            ,'Table'[Status] = "Approved"
        )
    RETURN
        CALCULATE( 
            SUM ( 'Table'[Cost] )
            ,KEEPFILTERS( 'Table'[Curr Ind] = "Current" )
            ,KEEPFILTERS( 'Table'[Status] = "Approved" )
            ,KEEPFILTERS( 'Table'[Seq] = _Seq )
        )
)

CurrentApproved.jpg

 

If this solves your issues please mark it as the solution. Kudos 👍 are nice too.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.