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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Nicho247
Helper III
Helper III

Cumulative Total Help - Slicer sets starting date

Hello - 

 

Working on a basic running/cumulative total. I have it working but it is grabbing all dates in my table. I'd like it to compute starting from the date present in a slicer. I've poked around quite a bit and unable to find an easy solution. As I have written the formula I can see the problem...how the code is going to go count everything. Hitting a wall with trial & error involving filters. Any help would be awesome!

 

The WKOCompletedDate goes back to 1/1/2019, and for example, my calendar date slicer is going from 1/1/2020. The graph is clearly controlled by the slicer but the calculated #'s are clearly starting from 1/1/2019. I believe I need to modify the below code to invoke some MIN function or SELECT/ALL SELECT. Ack!

 

Cumulative OnTime =
COUNTROWS(
FILTER(
GENERATE(WKO,'Calendar'),
WKO[CompletedDate] <= MAX('Calendar'[Date])))
19 REPLIES 19
Ashish_Mathur
Super User
Super User

Hi,

Does this measure work?

=CALCULATE(COUNTRWS(WKO),DATESBETWEEN('Calendar'[Date],MIN('Calendar'[Date]),TODAY()))

Ensure that the Data slicer is built from the Calendar table and you select 1/1/2020 there.

Hope this helps.


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

Hello Ashish -

 

Thank you for your recommendation. Unfortunately this is just outputting flat lines across all times. This is not a running total.

 

Cumulative4.PNG

 

 

Hi,

Does this measure work?

=CALCULATE(COUNTROWS(WKO),DATESYTD(Calendar[Date],"31/12"))


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

Hello Ashish - No sir. This is similiar to last time with a flat bar (not running total).

Hi,

Is this what you want?  Download the PBI file from here.

Hope this helps.

Untitled.png


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

Hello Ashish - No, this doesn't work. These are not running totals and is not affected by the slider. Did you upload the right file? Can you demonstrate how this answers my question? Unsure if I am missing something here.

Hi,

Share the link from where i can download your PBI file.


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

Hello Ashish - 

 

Here ya go. This is with some sample data.  Should be good enough to replicate the issue. Have a generic calendar table. Have another table with some dates. How to make the slider control the starting point for a running total/cumulative total.

 

Nick

 

https://1drv.ms/u/s!AlWk_fvRgbyDoDsGBjSdaNP6D7aS?e=5ezNqx

 

Hi,

 

For your sample02, please try this measure:

 

Measure = 
CALCULATE (
    COUNTROWS ( WKO ),
    FILTER (
        WKO,
        WKO[CompletedDate] <= MAX ( 'Calendar'[Date] )
            && WKO[CompletedDate] <> BLANK ()
    )
) + 0

 

The result shows:

6.PNG

See my attached pbix file.

 

Best Regards,

Giotto

Hello Giotto - No, this doesn't work. It is no different than my initial submission. If I take your file and change the slider date, the running total calculate is unaffected. E.G. here is a pic from your file.

 

With a date of 3/20, the graph should start at 0, but is starting at 54. In other words the running total is calculated independently of the slider.

 

Cumulative5.PNG

 

Hi,

 

Please try to create a duplicate calendar table first.

Choose calendar_2[date] as a slicer and calendar[date] as visual's x-axis. 

Then try this measure:

Measure = 
CALCULATE (
    COUNTROWS ( WKO ),
    FILTER (
        WKO,
        WKO[CompletedDate] <= MIN ( 'Calendar_2'[Date] )
            && WKO[CompletedDate] <> BLANK ()
            && WKO[CompletedDate] <= SELECTEDVALUE ( 'Calendar'[Date] )
    )
) + 0

Add this measure to the visual, the result shows:

1.PNG

See my attached pbix file.

 

Best Regards,

Giotto

Hello Giotto - This is an interesting idea with two calendar tables. Note, in your screenshot, the slider does not appear to control the graph nor the data. If it was doing either then the x-axis would reflect the slider dates and the running total wouldn't start so soon. Clearly is startin in January while the slider minimum is set to March. So this doesn't work.

Ok. Finally got it. Have to make a nested calculate to determine the minimum selected date from the slicer, then limit the wko rows by this min date and then start the running total.

 

MyCumulativeOnTime =
Calculate (
CountRows (
FILTER(
WKO, WKO[CompletedDate] >= CALCULATE(MIN('Calendar'[Date]),ALLSELECTED('Calendar'[Date])) && WKO[CompletedDate] <= MAX('Calendar'[Date]))))
v-gizhi-msft
Community Support
Community Support

Hi,

 

Please try to delete the relationship between 'WKO' table and 'calendar' table.

Then try this measure:

Cumulative OnTime =
CALCULATE (
    COUNTROWS ( WKO ),
    FILTER ( WKO, WKO[CompletedDate] >= SELECTEDVALUE ( 'Calendar'[Date] ) )
)

Hope this can help.

 

Best Regards,

Giotto

Hello Giotto - Thank you for your recommendation. Unfortunately this provides a bizarre reverse cumulative total. It does appear to be affected by the date sliders but not in the inteded fashion.  Unsure if it is also counting from the data set or from the sliders. Visually the slider is taken into account.

 

Cumulative3.PNG

Hi,

 

Please try this:

Cumulative OnTime =
CALCULATE (
    COUNTROWS ( WKO ),
    FILTER ( WKO, WKO[CompletedDate] <= SELECTEDVALUE ( 'Calendar'[Date] ) )
)

Or this:

Cumulative OnTime =
CALCULATE (
    COUNTROWS ( WKO ),
    FILTER (
        ALLSELECTED ( WKO ),
        WKO[CompletedDate] <= SELECTEDVALUE ( 'Calendar'[Date] )
    )
)

 

Best Regards,

Giotto

Hello Giotto -

 

The first measure does create the running total, but it unaffected by the slicer data. 

 

The second measure also creates the running total but removes the ability to use the legend, and is unaffected by the slicer data.

 

😞

 

Nick

amitchandak
Super User
Super User

@Nicho247 , Make sure you have all the dates in your calendar. Try


Cumulative OnTime =
calculate(COUNTROWS(WKO),
FILTER(all(WKO), WKO[CompletedDate] <= MAX('Calendar'[Date])))

or

Cumulative OnTime =
calculate(COUNTROWS(WKO),
FILTER(allselected(WKO), WKO[CompletedDate] <= MAX('Calendar'[Date])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Bummer. Neither of those work. No different than what mine was doing, but both drop the ability to breakdown the running total by legend (aka only 1 line).

 

The beginning of my dataset on WKO table is 1.1.2019.

 

Here is pic1.  My date slicer also reads 1.1.2019. Cumulative totals on all start at 0.

Cumulative1.PNG

 

Here is pic2. My date slicer has been changed to 1/1/2020. Cumulative totals should start at 0 but dont.

Cumulative2.PNG

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.