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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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