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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MichelleRoberts
Regular Visitor

Running Total Help

Hello!

I have a data set that looks like this:

Data.png

Where

Demand = WeeklyTriggerHrs + TotalHoursCurrent + TotalHrsPastDue

AvgHoursPW = (Sum of run_mch_hrs_per_day)*6

Demand-HoursPW = Demand - AvgHoursPW

 

I'm having trouble with the RunningTotalDemand-HrsPWHrs. As you can see, it's not creating a running total. Here's the formula I've got so far:

RunningTotalDemand-HrsPWHrs =
    CALCULATE(
        [Demand-HoursPW],
        FILTER(
            ALL('Calendar'),
            'Calendar'[Date] <= MAX('Calendar'[Date])
        )
    )
 
Can someone see where my error is? I also don't want it to add anything if there is no demand and the date is in the past, but I do want it to add if there is no demand and the date is current.

 

9 REPLIES 9
BeaBF
Super User
Super User

@MichelleRoberts Hi!

Try with:

RunningTotalDemand-HrsPWHrs =
VAR CurrentDate = MAX('Calendar'[Date])
RETURN
CALCULATE(
SUMX(
FILTER(
ALL('Calendar'),
'Calendar'[Date] <= CurrentDate
),
IF(
[Demand] > 0 || 'Calendar'[Date] = CurrentDate,
[Demand-HoursPW],
0
)
)
)

If it's ok please accept my answer as solution, instead, paste me some sample data plis

 

BBF

It's still not calculating correctly. I exported the data to Excel so I could calculate it and compare the two. See below.

Data2.png

@MichelleRoberts adjusted:

 

RunningTotalDemand-HrsPWHrs =
VAR CurrentDate = MAX('Calendar'[Date])
RETURN
CALCULATE(
SUMX(
FILTER(
ALL('Calendar'),
'Calendar'[Date] <= CurrentDate
),
IF(
[Demand] > 0 || 'Calendar'[Date] = CurrentDate,
[Demand-HoursPW],
0
)
),
ALLEXCEPT('Calendar', 'Calendar'[Date])
)

 

BBF

I now get this as a result:

Data3.png

@MichelleRoberts can you paste the data? so that i can do copy paste into a power bi and do some tests. 

 

meanwhile try with:

 

RunningTotalDemand-HrsPWHrs =
VAR CurrentDate = MAX('Calendar'[Date])
RETURN
CALCULATE(
SUMX(
FILTER(
ALL('Calendar'),
'Calendar'[Date] <= CurrentDate
),
IF(
[Demand] > 0 || 'Calendar'[Date] = CurrentDate,
[Demand-HoursPW],
BLANK() -- Use BLANK() instead of 0 to avoid adding zero values
)
)
)

 

BBF

It's still not working. Here's the data:

Year-WeekwcDemandAvgHoursPWDemand-HoursPWRunningTotalDemand-HrsPWHrsWeeklyTriggerHrsTotalHrsCurrentTotalHrsPastDueSum of run_mch_hrs_per_day
2023-24CELL A0.1614.85874-14.6987016.45821 0.162.476457
2024-01CELL A17.2982114.858742.439471-14.698716.458210.84 2.476457
2024-20CELL A0.7214.85874-14.1387-28.837516.45821 0.722.476457
2024-21CELL A1.4814.85874-13.3787-42.216216.45821 1.482.476457
2024-22CELL A7.6814.85874-7.17874-68.393716.45821 7.682.476457
2024-23CELL A6.9614.85874-7.89874-92.231216.45821 6.962.476457
2024-24CELL A25.3314.8587410.47126-128.73716.45821 25.332.476457
2024-25CELL A36.614.8587421.74126-179.02216.45821 36.62.476457
2024-26CELL A5.714.85874-9.15874-237.10716.45821 5.72.476457
2024-27CELL A119.2514.85874104.3913-235.74416.45821 119.252.476457
2024-28CELL A697.214.85874682.3413-145.25716.45821 697.22.476457
2024-29CELL A466.8614.85874452.0013-100.27116.45821 466.862.476457
2024-30CELL A349.314.85874334.4413-54.334716.45821 349.32.476457
2024-31CELL A3476.80814.858743461.949016.458211780.551679.82.476457
2024-32CELL A5114.92814.858745100.069016.458215098.47 2.476457
2024-33CELL A9450.05814.858749435.199016.458219433.6 2.476457
2024-34CELL A7518.21814.858747503.359016.458217501.76 2.476457
2024-35CELL A17233.7614.8587417218.9016.4582117217.3 2.476457
2024-36CELL A5676.53814.858745661.679016.458215660.08 2.476457
2024-37CELL A4802.77814.858744787.919016.458214786.32 2.476457
2024-38CELL A46648.514.8587446633.64016.4582146632.04 2.476457
2024-39CELL A22730.0614.8587422715.2016.4582122713.6 2.476457
2024-40CELL A4930.05814.858744915.199016.458214913.6 2.476457
2024-41CELL A7827.07814.858747812.219016.458217810.62 2.476457

@MichelleRoberts  based on this data, this formula works for me:

 

CumulativeDemandHoursPW =
VAR CurrentYearWeek = SELECTEDVALUE('Table'[Year-Week])
RETURN
CALCULATE(
    SUM('Table'[Demand-HoursPW]),
    FILTER(
        ALL('Table'),
        'Table'[Year-Week] <= CurrentYearWeek
    )
)
 
BeaBF_0-1722439099549.png

 

 

BBF

I see that it works for you but it's still not working for me. I'm going to try something else.

 

Data4.png

@MichelleRoberts can you upload the pbix in drive and share the link? so that i can work on your version.

 

BBF

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.