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
sabd80
Helper IV
Helper IV

Running Total Per Month

Hi,

I want to get running total per day and month, most of the measures have filter on date like below:

 

filter(all('Date'),'Date'[date] <=max('Date'[date])

 

but when I do that the running total starts from the available data, not what is on the visual.

so I have to add another filter on the date.

 

this is my measure:

Testing Qty Shipped RT Day =
VAR SelectedDate = CALCULATE( min('Calendar - Requested Date'[Calendar Date]), ALLSELECTED('Calendar - Requested Date'[Calendar Date]))
return
CALCULATE([Quantity Shipped],
        FILTER(ALL('Calendar - Requested Date'),
                'Calendar - Requested Date'[Calendar Date]<= max('Calendar - Requested Date'[Calendar Date]) &&
                   'Calendar - Requested Date'[Calendar Date]>= SelectedDate
))
 
The other issue I have is when I add the month to the visual, the running total does not work, like below:
 
2022-12-12_9-29-10.png

Do I need to create another measure for the monthly view?

1 ACCEPTED SOLUTION
sabd80
Helper IV
Helper IV

I found this below dax somewherelse and it is doing what it should:

Testing Qty Shipped RT =
CALCULATE([Quantity Shipped],
       FILTER(ALLSELECTED('Calendar - Requested Date'), 'Calendar - Requested Date'[Calendar Date]<= max('Calendar - Requested Date'[Calendar Date]))
 
Thanks for everyone's help.
       
)

View solution in original post

9 REPLIES 9
sabd80
Helper IV
Helper IV

I found this below dax somewherelse and it is doing what it should:

Testing Qty Shipped RT =
CALCULATE([Quantity Shipped],
       FILTER(ALLSELECTED('Calendar - Requested Date'), 'Calendar - Requested Date'[Calendar Date]<= max('Calendar - Requested Date'[Calendar Date]))
 
Thanks for everyone's help.
       
)
Ashish_Mathur
Super User
Super User

Hi,

Follow this process

1. Create a Calendar Table with calculated column formulas for Year, Month name and Month number

2. Sort the Month name column by the Month number

3. Create a relationship (Many to One and Single) from the Date column of your Data Table to the Date column of the Calendar Table

4. To your visual, drag Year, Month name and Date from the Calendar Table

5. Write these measures

Quantity Shipped = SUM('Sales Order Details'[Unit Quantity Shipped])
Quantity shipped YTD = calculate([quantity shipped],datesytd(calendar[date],"31/12"))

Hope this helps.


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

@Ashish_Mathur , thanks for your reply, I don't want YTD, I just need cummulative of the dates in the visuals.

Hi,

See if this measure works

Quantity shipped YTD = calculate([quantity shipped],datesbetween(calendar[date],minx(allselected(),Calendar[Date]),max(calendar[date])))

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

there is something wrong with syntax inside minx.

grandtotal
Resolver III
Resolver III

You should use the concept described here by SQLBI:
https://www.sqlbi.com/articles/computing-running-totals-in-dax/

 

Sales RT :=
VAR MaxDate = MAX ( 'Date'[Date] ) -- Saves the last visible date
RETURN
    CALCULATE (
        [Sales Amount],           -- Computes sales amount
        'Date'[Date] <= MaxDate,  -- Where date is before the last visible date
        ALL ( Date )              -- Removes any other filters from Date
    )

 

I hope this will help you!

@grandtotal , I have tried that, it does not work for daily and monthly.

 

Testing Qty Shipped RT Month2 =
VAR SelectedDate =  max('Calendar - Requested Date'[Calendar Date])
VAR QtyShippedRT=
CALCULATE([Quantity Shipped],
        'Calendar - Requested Date'[Calendar Date]<= max('Calendar - Requested Date'[Calendar Date]), ALL('Calendar - Requested Date')
       
)
return
QtyShippedRT
 
2022-12-12_10-22-39.png

can you post the definiton of [Quantity Shipped]?

Quantity Shipped = SUM('Sales Order Details'[Unit Quantity Shipped])

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.