cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lucasrm
Frequent Visitor

Find first date where a cumulative total condition is met

Hello community!

 

I'm struggling with a measure and would appreciate if anyone could help!

Here's what I'm trying to do:


I have a physical table of sales amount by employee by date like this:

Name | Amount | Date

John | 500 | 10/04/21
Amanda | 700 | 12/04/21
John | 400 | 15/04/21

I want to create a measure (no custom column allowed since I'm using a shared dataset) where, for each employee, I'll get the first date where they achieved cumulative 600 or more in sales. For Amanda, the result would be 12/04/21. For John, the result would be 15/04/21.

 

I tried creating a virtual table using SUMMARIZE with the cumulative sum and getting the first date in this table but it doesn't work.

 

Thanks in advance!

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@lucasrm 

please try this

Measure = 
VAR tbl=ADDCOLUMNS('Table (2)',"ytdamount",sumx(FILTER('Table (2)','Table (2)'[name]=EARLIER('Table (2)'[name])&&'Table (2)'[date]<=EARLIER('Table (2)'[date])),'Table (2)'[amount]))
return MINX(FILTER(tbl,[ytdamount]>600),'Table (2)'[date])

please 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

3 REPLIES 3
ryan_mayu
Super User
Super User

@lucasrm 

please try this

Measure = 
VAR tbl=ADDCOLUMNS('Table (2)',"ytdamount",sumx(FILTER('Table (2)','Table (2)'[name]=EARLIER('Table (2)'[name])&&'Table (2)'[date]<=EARLIER('Table (2)'[date])),'Table (2)'[amount]))
return MINX(FILTER(tbl,[ytdamount]>600),'Table (2)'[date])

please see the attachment below





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

Proud to be a Super User!




That's it! Thank you very much! I had no idea we could set a virtual table to a variable.

you are welcome





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

Proud to be a Super User!




Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors