Forum Discussion
Cumulative count on two different dates columns
Below is my data:
| ID | Date Created | Date Cancelled |
| 1 | 01.01.2022 | |
| 2 | 01.02.2022 | |
| 3 | 15.02.2022 | |
| 4 | 01.03.2022 | |
| 5 | 03.03.2022 | |
| 6 | 27.03.2022 | |
| 7 | 01.04.2022 | |
| 8 | 01.05.2022 | |
| 9 | 02.05.2022 | 03.05.2022 |
I want to be able to show a cumulative count as below:
| Cumulative count on date 27.03.2022 | 6 |
| Cumulative count at date 03.05.2022 | =9-1=8 |
I want to be able to show the cumulative count based on these two dates.
- Anonymous4 years ago
Hi klaritak ,
Please refer to my pbix file to see if it helps you.
Create measures.
Cumulative count on date 27.03 = VAR _max_id = CALCULATE ( MAX ( 'Table'[ID] ), FILTER ( ALL ( 'Table' ), 'Table'[Date Created] = DATE ( 2022, 3, 27 ) ) ) RETURN CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALL ( 'Table' ), 'Table'[ID] <= _max_id ) )Cancelled = VAR _created = CALCULATE ( COUNTROWS ( 'Table' ), ALL ( 'Table' ) ) VAR caleled = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALL ( 'Table' ), 'Table'[Date Cancelled] <> BLANK () ) ) RETURN _created - caleledIf I have misunderstood your meaning, please provide the details. Why did you want to calculate Cumulative count on date 2022.03.27.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- amitchandakSuper User
klaritak , Join both the dates with date table , Assume one join is inactive assume that is Date Cancelled
Create measures
Created = count(Table[ID])
Cancelled= calculate(count(Table[ID]),USERELATIONSHIP ('Table'[Date Cancelled], 'Date'[Date]), not(isblank('Table'[Date Cancelled])) )
Then create measure
Cumm Sales = CALCULATE([Created] - [Cancelled],filter(allselected(date),date[date] <=max(date[Date])))
use date from date table in visual and slicer
Also check - https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
- klaritakFrequent Visitor
Hey amitchandak,
Thank you very much for your reply.
This formula is not working: Cancelled= calculate(count(Table[ID]),USERELATIONSHIP ('Table'[Date Cancelled], 'Date'[Date]), not(isblank('Table'[Date Cancelled])))
I get the following error (Too many arguments were passed to the USERELATIONSHIP function. The maximum argument count for the function is 2.)
- AnonymousNot applicable
Hi klaritak ,
Please refer to my pbix file to see if it helps you.
Create measures.
Cumulative count on date 27.03 = VAR _max_id = CALCULATE ( MAX ( 'Table'[ID] ), FILTER ( ALL ( 'Table' ), 'Table'[Date Created] = DATE ( 2022, 3, 27 ) ) ) RETURN CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALL ( 'Table' ), 'Table'[ID] <= _max_id ) )Cancelled = VAR _created = CALCULATE ( COUNTROWS ( 'Table' ), ALL ( 'Table' ) ) VAR caleled = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( ALL ( 'Table' ), 'Table'[Date Cancelled] <> BLANK () ) ) RETURN _created - caleledIf I have misunderstood your meaning, please provide the details. Why did you want to calculate Cumulative count on date 2022.03.27.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.