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

View all the Fabric Data Days sessions on demand. View schedule

Reply
shaoboji
Frequent Visitor

How to get the first or last value in a column?

Hi everyone, need a little help here:

In a table like this:

date        rank

1/1/2000    2

1/2/2000    1

1/3/2000    3

1/4/2000    2

 

I want to get the first or last value of rank, so both are 2 in this case. But with FirstNonBlank or LastNonBlank, the result is always in asc or desc order, getting 1 and 3. Any ideas? Thanks.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@shaoboji  - You can creat a Measure like this:

Find First = 
var __EarliestDate = MIN(YourTable[Date])
return CALCULATE(MIN(YourTable[Rank]), YourTable[Date] = __EarliestDate )

Hope this helps,

Nathan

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

@shaoboji  - You can creat a Measure like this:

Find First = 
var __EarliestDate = MIN(YourTable[Date])
return CALCULATE(MIN(YourTable[Rank]), YourTable[Date] = __EarliestDate )

Hope this helps,

Nathan

 

DouweMeer
Impactful Individual
Impactful Individual

@Anonymous 

 

I was curious. Why are you using "__" in front of the VAR name?

Anonymous
Not applicable

@DouweMeer  - I don't always use it, but it's a way to easily identify variables when reading the code. Notably, visuals use this format for variables in their behind-the-scenes DAX. It also offers some protection from re-using a keyword or existing column/measure/table name.

DouweMeer
Impactful Individual
Impactful Individual

@Anonymous  Fair enough. Thought it might had something to do with standard practice in other languages. 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors