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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ElenaJ
Frequent Visitor

Running Total with Blank Month Value

Hi,

I created a measure for a running total by month, the coding used is:

 

Cumulative = CALCULATE(
    SUM('Schedule'[Forecast]),
    USERELATIONSHIP(CalendarM[Date],'Schedule'[Forecasted Date]),
    FILTER(
        ALLSELECTED('CalendarM'[Date]),
        ISONORAFTER('CalendarM'[Date], MAX('Schedule'[Forecasted Date]), DESC)
    )
)
 
However, the visual I have (1)skips the months with no value and (2) has blank value for some months.
ElenaJ_0-1663222857170.png

I want a  running total for every month, if there is no value for that month, just carry the previous month's value forward. Would appreciate if someone can advise how to revise the DAX?

1 ACCEPTED SOLUTION

Hi,

Thank you for your feedback.

Please check the below if it suits your requirement.

 

-Jun value shows in the table visualization

-only upto Nov values are shown.

 

Jihwan_Kim_0-1663306764288.png

 

Cumulative = 
VAR _lastdateinscheduletable =
    CALCULATE ( MAX ( Schedule[Forecasted Date] ), REMOVEFILTERS () )
RETURN
    CALCULATE (
        SUM ( 'Schedule'[Forecast] ),
        USERELATIONSHIP ( CalendarM[Date], 'Schedule'[Forecasted Date] ),
        FILTER (
            ALLSELECTED ( 'CalendarM' ),
            CalendarM[Date] <= MAX ( CalendarM[Date] )
                && CalendarM[Year] = MAX ( CalendarM[Year] )
                && MIN ( CalendarM[Date] ) <= _lastdateinscheduletable
        )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

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/
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1663225562716.png

Cumulative =
CALCULATE (
    SUM ( 'Schedule'[Forecast] ),
    USERELATIONSHIP ( CalendarM[Date], 'Schedule'[Forecasted Date] ),
    FILTER (
        ALLSELECTED ( 'CalendarM' ),
        CalendarM[Date] <= MAX ( CalendarM[Date] )
            && CalendarM[Year] = MAX ( CalendarM[Year] )
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

For example, in the schedule table, 7if we don't have any June dates in the Forecasted Date, how can we calculate a culmulative value without skipping June?

 

Forecasted DateForecast

Sunday, 1 May 20225
  
Friday, 1 July 20223
Monday, 1 August 20224
Thursday, 1 September 20227
Saturday, 1 October 20226
Tuesday, 1 November 20229

Hi,

Thank you for your feedback.

Please check the below if it suits your requirement.

 

-Jun value shows in the table visualization

-only upto Nov values are shown.

 

Jihwan_Kim_0-1663306764288.png

 

Cumulative = 
VAR _lastdateinscheduletable =
    CALCULATE ( MAX ( Schedule[Forecasted Date] ), REMOVEFILTERS () )
RETURN
    CALCULATE (
        SUM ( 'Schedule'[Forecast] ),
        USERELATIONSHIP ( CalendarM[Date], 'Schedule'[Forecasted Date] ),
        FILTER (
            ALLSELECTED ( 'CalendarM' ),
            CalendarM[Date] <= MAX ( CalendarM[Date] )
                && CalendarM[Year] = MAX ( CalendarM[Year] )
                && MIN ( CalendarM[Date] ) <= _lastdateinscheduletable
        )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

This answer has helped resolve my question too. Much appreciated! Now I'm trying to get a new measure for calculating the running total of previous year in same way. Could you provide some guidance? Thank you

It worked! Amazing!

Many thanks for your help!

Thanks for the suggestion.

 

My problem is that I created a 10 year calendar that link to the dates in the schedule table. While the schedule table only runs to a certain month in 2023. I want the running total to add up to the last date on the schedule table instead of the calendar table.

Anonymous
Not applicable

Hi @ElenaJ ,

Could you share which table are you using to derived month column in your matrix?

Dax_Noob_0-1663225030158.png

 


BR

Sure. I created a ten year calendar table called calendarM (2020-2030) and linked it to my fact table schedule. Calendar M has date and month/year columns. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.