Forum Discussion

yogeshk77's avatar
yogeshk77
Helper I
4 years ago
Solved

Get Second highest value

I have following tables

Build table with Code Coverage

 

Mapping table - Work Item ID & Build ID

And Work Item table

 

 

Now, I have a measure that gives me the latest Build ID (from that second table of Build ID & Work Item ID)

 

And with that I am fetching relevant Build Repo & Code Coverage in that third table

 

Hence in the third table as shown above, I am getting the latest Code Coverage against the work item & repo.

 

Now, what I need is, to get the previous Code Coverage in that third table shown above.

For that I need a measure in this third table, to get the second highest 'build ID' from the build table (First Table), for that respective 'Build Repo' column value in the Third table.

How can I use Lookup to do that?

  • Hi,

    You can create a measure with the following logic:

    Start data:


    Dax:

    Second latest build =
    var latest = MAX('Matrix example'[Company]) return
    CALCULATE(MAX('Matrix example'[Company]),'Matrix example'[Company]<>latest) //Exclude the latest from MAX
    End result:

    I hope this helps and if it does consider accepting this as a solutio nand giving the post a thumbs up!

3 Replies

  • ValtteriN's avatar
    ValtteriN
    Community Champion

    Hi,

    You can create a measure with the following logic:

    Start data:


    Dax:

    Second latest build =
    var latest = MAX('Matrix example'[Company]) return
    CALCULATE(MAX('Matrix example'[Company]),'Matrix example'[Company]<>latest) //Exclude the latest from MAX
    End result:

    I hope this helps and if it does consider accepting this as a solutio nand giving the post a thumbs up!

  • smpa01's avatar
    smpa01
    Community Champion

    yogeshk77  provide sample data in a tabke format/ create a sample pbi, upload in 1/g drive and share the link here

  • CQueen's avatar
    CQueen
    Frequent Visitor

    I kept getting True/False errors with this solution