Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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
Solved! Go to Solution.
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.
Proud to be a 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.
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.
Proud to be a 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.
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 )
)
)
If this solves your issues please mark it as the solution. Kudos 👍 are nice too.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 39 | |
| 37 | |
| 29 | |
| 24 |
| User | Count |
|---|---|
| 119 | |
| 100 | |
| 72 | |
| 69 | |
| 65 |