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
Imv_OrdixAG
New Member

Creating a DAX Measure for Dynamic Cumulative Total

Hello fellow experts in Power BI and DAX,

I'm looking for assistance in creating a DAX measure that can effectively subtract the cumulative total of summed available worker capacity hours from their remaining order volume for a specific project. The cumulative total should be dynamically calculated from the current date to the user-selected end date, using a date slicer. The objective is to generate a forecast answering how workers will allocate their available capacity to fulfill the remaining order volume for the project.

To provide more context, I have a fact table with primary keys for each worker, project, date (daily granularity), a specific value type, and a numeric value column indicating hours.

Here are simplified examples of the data in Excel:

project_nrworker_nr  datevalue_typevalue  
1201.04.2023Total ordered hours1200
2101.01.2023Total ordered hours800
3401.03.2023Total ordered hours1000

Example data for total order volume

project_nr  worker_nr  datevalue_type  value  
1202.04.2023Paid hours8
1203.04.2023Paid hours8
1204.04.2023Paid hours8
1205.04.2023Paid hours8
1206.04.2023Paid hours8
1207.04.2023Paid hours4
1208.04.2023Paid hours8
1209.04.2023Paid hours8
1210.04.2023Paid hours6
1211.04.2023Paid hours8

Example data for paid hours
To calculate the remaining order volume, I have a measure subtracting the total order volume from the accomplished paid hours (again simplified):

Remaining order volume =
IFERROR (
    [Total order volume]
        CALCULATE (
            SUM ( 'f_hours'[value] ),
            'f_hours'[value_type] = "Paid hours",
            ALL ( d_date[date] )
        ),
    0
)
DAX-Measure for the remaining order volume


For available capacity, I use a simple measure with calculate to obtain the sum of the capacity (same as the paid hours calculate statement).

project_nr  worker_nr  datevalue_typevalue  
null201.09.2023Available capacity8
null202.09.2023Available capacity8
null203.09.2023Available capacity8
null204.09.2023Available capacity8
null205.09.2023Available capacity8
null206.09.2023Available capacity8
null207.09.2023Available capacity6
null208.09.2023Available capacity8
null209.09.2023Available capacity8
null210.09.2023Available capacity8
null211.09.2023Available capacity8

Example data for available capacity

 

Here's an example of the desired outcome:

Remaining order volume  Available capacity cumulative total  Date
600801.09.2023
5921602.09.2023
5842403.09.2023
5763204.09.2023
5684005.09.2023
5604806.09.2023
5545407.09.2023
5466208.09.2023
5387009.09.2023
5307810.09.2023
5228611.09.2023

 

I initially explored using the TOTALYTD function, but it reset the remaining order volume each year if it wasn't fully accomplished by year-end:

Cumulative Subtraction Remaining Volume =
VAR StartDate =
    TODAY ()
VAR EndDate = [MaxDate]
RETURN
    IF (
        SELECTEDVALUE ( d_date[date] ) >= StartDate
            && SELECTEDVALUE ( d_date[date] ) <= EndDate
            && (
                [Remaining order volume]
                    TOTALYTD (
                        [Capacity available],
                        d_date[date],
                        d_date[date] >= StartDate
                            && SELECTEDVALUE ( d_date[date] ) <= EndDate
                    )
            ) >= 0,
        [Remaining order volume]
            TOTALYTD (
                [Capacity available],
                d_time[date],
                d_time[date] >= StartDate
                    && SELECTEDVALUE ( d_date[date] ) <= EndDate
            ),
        BLANK ()
    )
DAX-Measure as a try for the cumulative subtraction of the remaining order volume

Imv_OrdixAG_0-1700064200603.png

Example of how the remaining order volume resets after the new year begins


What I need is a custom TOTALYTD function allowing me to specify a date range from the current date to the maximum date selected by the user. I've attempted examples from this forum like:

Cumulative total =
SUMX (
    FILTER (
        ALL ( d_date[date] ),
        d_date[date] >= TODAY ()
            && d_date[date] <= [MaxDate]
    ),
    [Capacity available]
)
Or the same measure but with CALCULATE instead of SUMX.

Unfortunately, these examples only sum the capacity for the filtered date range and don't fulfill my requirements. Any guidance or alternative approaches for the measure or the model of the fact table would be greatly appreciated. Also if you need any more data examples, feel free to ask. 

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@Imv_OrdixAG You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

 

Also, this:



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.