Reply
kattlees
Post Patron
Post Patron

Get value of column based on lastest date

I have a column with AcctNum, Insurance, Date, Status, Paid Date

Entries may look like this

123456        CB          12-14-18              PAID                   2-14-18
123456        MPA       1-16-18               REJECTED            2-16-18

123456        MBI        2-16-18               BILLED         

654321        CPA       1-15-18                BILLED

654321        CB          1-15-18               BILLED

 

I need to get the Insurance Value from the last entry

 

So for 123456, I would need to get MBI 

For 654321 I would get CB

1 ACCEPTED SOLUTION

If you add an index column and you data looks like the following:

 

Capture.PNG

 

Then to get the results you desire, then use the following formula:

Measure = 
CALCULATE(
    MAX(Table1[Insurance]),
    FILTER(Table1,Table1[Index] = MAX(Table1[Index]))
)

And you will get the correct results:

Capture1.PNG

View solution in original post

3 REPLIES 3
vega
Resolver III
Resolver III

I think you would have to add some sort of index that increases incrementally as you add entries. I don't believe DAX has a way to access the entry order of records. 

If I add an index column, what would it take to get the latest one?

If you add an index column and you data looks like the following:

 

Capture.PNG

 

Then to get the results you desire, then use the following formula:

Measure = 
CALCULATE(
    MAX(Table1[Insurance]),
    FILTER(Table1,Table1[Index] = MAX(Table1[Index]))
)

And you will get the correct results:

Capture1.PNG

avatar user

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)