Forum Discussion

topazz11's avatar
topazz11
Icon for Helper III rankHelper III
6 years ago
Solved

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 t...
  • JarroVGIT's avatar
    6 years ago

    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.