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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
yogeshk77
Helper I
Helper I

Get Second highest value

I have following tables

Build table with Code Coverage

yogeshk77_0-1641461871839.png

 

Mapping table - Work Item ID & Build ID

yogeshk77_1-1641461912268.png

And Work Item table

 

yogeshk77_2-1641461952420.png

 

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

yogeshk77_3-1641462000018.png

 

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

yogeshk77_4-1641462079101.png

yogeshk77_5-1641462110075.png

 

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?

1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

You can create a measure with the following logic:

Start data:

ValtteriN_0-1641464479302.png


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:

ValtteriN_1-1641464536130.png

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





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

Proud to be a Super User!




View solution in original post

3 REPLIES 3
CQueen
Frequent Visitor

I kept getting True/False errors with this solution

smpa01
Super User
Super User

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

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
ValtteriN
Super User
Super User

Hi,

You can create a measure with the following logic:

Start data:

ValtteriN_0-1641464479302.png


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:

ValtteriN_1-1641464536130.png

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





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

Proud to be a Super User!




Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.