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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mscabrera
Helper I
Helper I

Perform calculations on unique values based on the last date

Hi!

I've been having troubles to get to the following result

I have a fact table where I have multiple projects (unique ID) but each project have multiple deliverables, in the table for example I have:

IDStartDateEndDateNumber of tasks
xxx-1231/01/202315/01/20231
xxx-1327/01/20237/02/20231
xxx-1427/02/20233/03/20231
xxx-1231/01/20231/02/20231
xxx-1233/01/202315/01/20231
xxx-1325/02/20238/02/20021

I need to count the projects delivered by month, but for example the project xxx-123 needs to count as delivered in in february, because it's the lastest date when a deliverable was made. I have a dim Date table connected to the EndDate and I've tried with this formula to get the result:
VAR _Summarized = SUMMARIZE(Table,  Table[ID], "MinStart", MIN(Table[StartDate]), MAX(Table[EndDate]))

RETURN COUNTROWS(_Summarized)

But when addind the data to a Matrix and putting months in the rows, it count the project xxx-123 both in january and february, and should only be in february that is the latest end date.

Plus I'm using the same logic and addind the StartDate in the summarized function, because I need to calculate the Average Cycle Tme of every ID (CT = EndDate - StartDate / 7) and this needs to be calculated with earliest StartDate and the Latest EndDate and that averga should affect the month in when the latest delivery was made.

For that pourpse I'm using the following dax formula:
VAR _Summarized = ADDCOLUMNS(SUMMARIZE(Table,  Table[ID], "MinStart", MIN(Table[StartDate]), MAX(Table[EndDate])), "CT", DIVIDE(Table[EndDate] -  MIN(Table[StartDate]), 7))

RETURN AVERAGEX(_Summarized, [CT])

and again, it is showing me the average cycle time for the project XXX-123 in january and also in february.

As always your help will be much appreciated

1 ACCEPTED SOLUTION

@mscabrera 

you can group by data in PQ and create a custom column

11.PNG

 

pls see the attachment below

 





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

Proud to be a Super User!




View solution in original post

7 REPLIES 7
mscabrera
Helper I
Helper I

@ryan_mayu  Thank you!

you are welcome





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

Proud to be a Super User!




ryan_mayu
Super User
Super User

@mscabrera 

try to create a new column 

end date2 = CALCULATE(max('Table'[EndDate]),ALLEXCEPT('Table','Table'[ID]))
11.PNG
 then connect the new column to your dim table. The project xxx-123 will be in the Feb




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

Proud to be a Super User!




Hi @ryan_mayu , thanks for the quick reply.

I noticed that when the relation between the dim date and the fact table is deactivated, the result is the expected... When I was looking for some solution to it, I managed to create the same column that you propose, but in powerquery, but I wanted to know if there is a solution in a measure that doesn't need the addition of additional columns 

what's the expected output based on the sample data you provided? 





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

Proud to be a Super User!




 @ryan_mayu 

This is the expected outcome:

mscabrera_0-1706578493265.png

Being Delivered the measure that count the number of unique ID delivered (last date delivered) and Cycle Time the the min DIVIDE(Max(EndaDate) - Min(StartDate), 7) 

@mscabrera 

you can group by data in PQ and create a custom column

11.PNG

 

pls see the attachment below

 





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

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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