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! Request now

Reply
Domenick
Helper IV
Helper IV

How can I only sum "last" values in a column?

I want to sum the values in the [Indicator] column. In some instances, there are two values for the same [EndDate]. In those cases, I only want to include the latest [RunTime]. In the example below, both have a 1 in [Indicator] but there could be two 0s or a 0 and a 1. 

 

I am intending to divide this number by a DistinctCount of [EndDate] so that I can get a sort of % complete score across all EndDates (each EndDate only needs to be evaluated once but is sometimes evaluated twice when the end of the month falls in the middle of the week). Note that this table only shows one employee, but there will be several hundred employees in the full table.

 

 

Domenick_0-1651175820722.png

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Domenick 

maybe you can create a new column to flag the last record

iflast = 
VAR _max=CALCULATE(max('Table'[last modify date]),ALLEXCEPT('Table','Table'[last modify by],'Table'[date]))
return if(_max='Table'[last modify date],"Y")

1.PNG





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

Proud to be a Super User!




View solution in original post

5 REPLIES 5
ryan_mayu
Super User
Super User

@Domenick 

maybe you can create a new column to flag the last record

iflast = 
VAR _max=CALCULATE(max('Table'[last modify date]),ALLEXCEPT('Table','Table'[last modify by],'Table'[date]))
return if(_max='Table'[last modify date],"Y")

1.PNG





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

Proud to be a Super User!




Thanks! This is a great ideas and it almost worked, but for some reason there are dates that aren't being flagged when they should. Any ideas?

 

Domenick_0-1651241348006.png

I'm using the code you suggested but with the appropriate column names: 

 

iflast = VAR _max=CALCULATE(max(OAC_Timesheet_Citizenship[RunTime]),ALLEXCEPT(OAC_Timesheet_Citizenship,OAC_Timesheet_Citizenship[Emp],OAC_Timesheet_Citizenship[EndDate]))
return if(_max=OAC_Timesheet_Citizenship[RunTime],"Y")

  

@Domenick 

maybe there are duplicated data for emp and end date. 

try below to check why the max datetime is not different from the runtime datetime. The DAX returns the max runtime date for the same emp and same enddate.

iflast = VAR _max=CALCULATE(max(OAC_Timesheet_Citizenship[RunTime]),ALLEXCEPT(OAC_Timesheet_Citizenship,OAC_Timesheet_Citizenship[Emp],OAC_Timesheet_Citizenship[EndDate]))
return _max

  





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

Proud to be a Super User!




Ah yes, you are correct. I was able to easily filter those out, and now it all works. Thank you again!

you are welcome





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

Proud to be a Super User!




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