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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
kishcolor
Frequent Visitor

How to create a measure that sums only the values of the most recent date.

We have the following data.
Among them, we want to extract only the latest value for each user and sum it up.

Screenshot 2021-11-03 172132.png

 

I tried to combine the TopN, RANKX and Filter functions, but could not get it to work.

If you have any good ideas, could you please let me know?

 

Best regards,

kishcolor

1 ACCEPTED SOLUTION
vojtechsima
Super User
Super User

Hi, @kishcolor 
I believe this measure could do it:

LatestSum =
var latestDate= CALCULATE(MAX(Table[Date]),
ALLEXCEPT(Table, Table[User]))
// optional - var latestSum = SUMX(FILTER(Table, Table[Date]=latestDate),Table[Amount]) // optional

return latestDate

If you seek a tailor-made solution for your specific table, please paste a copyable sample data.

View solution in original post

5 REPLIES 5
vojtechsima
Super User
Super User

Hi, @kishcolor 
I believe this measure could do it:

LatestSum =
var latestDate= CALCULATE(MAX(Table[Date]),
ALLEXCEPT(Table, Table[User]))
// optional - var latestSum = SUMX(FILTER(Table, Table[Date]=latestDate),Table[Amount]) // optional

return latestDate

If you seek a tailor-made solution for your specific table, please paste a copyable sample data.

@vojtechsima 

When I use your formula, it only shows of the latest values, is it possible to sum the latest values for each user?

"The "300" is the most recent value of the whole, but we actually want to display the most recent value for each user, which is "930.

image.png

 

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@kishcolor , Try a measure like

 

Measure =
VAR __id = MAX ('Table'[User] )
VAR __date = CALCULATE ( MAX('Table'[Date] ), ALLSELECTED ('Table' ), 'Table'[User] = __id )
CALCULATE ( sum ('Table'[Amount] ), VALUES ('Table'[User] ),'Table'[User] = __id,'Table'[Date] = __date )

 

or

 

CALCULATE ( lastnonblankvalue('Table'[Date], sum ('Table'[Amount] )),allexcept('Table', 'Table'[User]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

Thank you for your answer.

Using your formula, I see the last user's total (=90), but is it possible to show the sum of each user's values (=930)?

image2.png

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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