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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
MSaunders206
Frequent Visitor

Cumulative total with dates that do not have values

I'm looking to create a measure that counts cumulative totals and just cannot seem to find the right solution.  I have a table called "tblWorkStatus" that looks like this:

Work_statusdate
12018-11-01
22018-06-01
32018-12-01
42018-06-01
52018-05-01
32018-10-01
32018-06-01
32018-03-01
32018-06-01
32019-11-01
32018-02-01
32018-03-01
32018-05-01
32018-12-01

 

I have another table called tblDate that has the first of the month dates for all dates between 2018-01-01 and 2019-12-01.

 

DateMonth
2018-01-011
2018-02-012
2018-03-013
2018-04-014
2018-05-015
2018-06-016
2018-07-017
2018-08-018
2018-09-019
2018-10-0110
2018-11-0111
2018-12-0112
2019-02-012
2019-03-013
2019-04-014
2019-05-015
2019-06-016
2019-07-017
2019-08-018
2019-09-019
2019-10-0110
2019-11-0111
2019-12-0112

 

I'd like to have a running cumulative total of all work status "3".  I've created a measure called "Total_to_Date", but what I really desire is "what_I_want".

 

Total_to_date:=calculate(counta(tblWorkStatus[Work_status]),tblWorkStatus[Work_status]=3,filter(all(tblDate[date]),tblDate[date]<=max(tblWorkStatus[date])))

 

DatesCount of Work StatusTotal_to_Datewhat_I_want
2018-01-01  0
2018-02-01111
2018-03-01233
2018-04-01  3
2018-05-01144
2018-06-01266
2018-07-01  6
2018-08-01  6
2018-09-01  6
2018-10-01177
2018-11-01  7
2018-12-01299
2019-02-01  9
2019-03-01  9
2019-04-01  9
2019-05-01  9
2019-06-01  9
2019-07-01  9
2019-08-01  9
2019-09-01  9
2019-10-01  9
2019-11-0111010
2019-12-01  10

 

I can't seem to figure out how to get my calculated measure to fill in total values if there is no corresponding work status for a given month.  I've pored over several posts on the forum to no avail.  Any help?

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

 

You may download my PBI file from here.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

12 REPLIES 12
Ashish_Mathur
Super User
Super User

Hi,

 

You may download my PBI file from here.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

This certainly has the behavior that I'm looking for.  I downloaded the PBIX file and am viewing with the web interface, but cannot seem to find the calculation for the "YTD work status count" field.  What is the formula for the calculation?

Hi,

 

In PowerBI desktop, click on the measure on the right hand side pane and you will see the measure in the formula bar.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Unfortunately for me, my workplace hasn't sprung for PowerBI desktop, so I am limited to the web interface and using PowerPivot in Excel.  So I can't confirm if the proposed solution works. 

You mean PowerBI service? PowerBI desktop is free.

You should be able to download the. PBIX and copy the DAX

You can do 95% of what you can do in PBI in PowerPivot and many people develop the data models in PowerPivot and then transfer to PowerBI.

Aha!  Thanks Seward!  Clearly my greenhorn is showing. 

So did my solution work?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Yes, elegantly.  Thanks!

Thank you for confirming.  Please mark my response as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I think I have done so? I did select "Accept as solution", and when I click on "Go to solution" in the original question it takes me to your solution.  As I mentioned I am pretty new to this so it is entirely possible that I didn't complete the process.  Don't hesitate to let me know if there is a further step.  Thanks again!

Seward12533
Solution Sage
Solution Sage

Your close need to specifybtbe date table name as a term in the calculate to force the filter context to between the two tables.

Total_to_date:=calculate(counta(tblWorkStatus[Work_status]),tblWorkStatus[Work_status]=3,tbleDate,filter(all(tblDate[date]),tblDate[date]<=max(tblWorkStatus[date])))

Thanks for the input Seward.  When I tried your formula, it gave me the same values as "Count of Work Status".

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.