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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Yazid
Helper I
Helper I

Cumulative sum between 2 distinct period

Dear,

 

I have a column date data, namely 'MERGED-COST SAVINGS'[Start date]

 

Remark: This last column has date from 01/01/24 to 31/12/2026

 

I would like to construct a graph of cumulative sum for:

 

First hand: summing values 'MERGED-COST SAVINGS'[Full Year Forecast 2024]) BETWEEN the PERIOD 01/01/24 to 31/12/2024

 

Second hand: summing values 'MERGED-COST SAVINGS'[Estimated 12 month impact] BETWEEN the PERIOD 01/01/25 to 31/12/2026

 

I have written DAX code (It wrong) just for you to understand my logic.

Yazid_0-1718116425299.png

 

Could you please let me know how to write a correct code ?

 

Thanks in advance for your support.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Yazid 

 

Based on your needs, I have created the following table.

 

vjialongymsft_0-1719475242701.png

 

You can use the following measure to calculate the cumulative sum:

Measure = 
VAR select_date = SELECTEDVALUE('Table'[Date])
RETURN
SUMX(FILTER(ALL('Table'),'Table'[Date]<=select_date),'Table'[Value])

 

 

This is the result you want:

vjialongymsft_1-1719475337116.png

 

 

 

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Yazid 

 

Based on your needs, I have created the following table.

 

vjialongymsft_0-1719475242701.png

 

You can use the following measure to calculate the cumulative sum:

Measure = 
VAR select_date = SELECTEDVALUE('Table'[Date])
RETURN
SUMX(FILTER(ALL('Table'),'Table'[Date]<=select_date),'Table'[Value])

 

 

This is the result you want:

vjialongymsft_1-1719475337116.png

 

 

 

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

rajendraongole1
Super User
Super User

Hi @Yazid create a cumulative sum of two different sets of data over specific periods. 

 

I am using the same dates as reference for summing values 'MERGED-COST SAVINGS'[Full Year Forecast 2024]) BETWEEN the PERIOD 01/01/24 to 31/12/2024.

 

Cumulative Sum 2024 =
VAR StartDate = DATE(2024, 1, 1)
VAR EndDate = DATE(2024, 12, 31)
RETURN
CALCULATE(
SUM('MERGED-COST SAVINGS'[Full Year Forecast 2024]),
FILTER(
'MERGED-COST SAVINGS',
'MERGED-COST SAVINGS'[Start date] >= StartDate &&
'MERGED-COST SAVINGS'[Start date] <= EndDate
),
FILTER(
ALL('MERGED-COST SAVINGS'[Start date]),
'MERGED-COST SAVINGS'[Start date] <= EndDate
)
)

 

create another measure for summing values 'MERGED-COST SAVINGS'[Estimated 12 month impact] BETWEEN the PERIOD 01/01/25 to 31/12/2026

 

Cumulative Sum 2025_2026 =
VAR StartDate = DATE(2025, 1, 1)
VAR EndDate = DATE(2026, 12, 31)
RETURN
CALCULATE(
SUM('MERGED-COST SAVINGS'[Estimated 12 month impact]),
FILTER(
'MERGED-COST SAVINGS',
'MERGED-COST SAVINGS'[Start date] >= StartDate &&
'MERGED-COST SAVINGS'[Start date] <= EndDate
),
FILTER(
ALL('MERGED-COST SAVINGS'[Start date]),
'MERGED-COST SAVINGS'[Start date] <= EndDate
)
)

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Dear,

 

Thanks for your reply. I've created the first function CumulativeSumFcst2024 as you mentionned.

 

However, the results are not cumulative (not a strict increasing function)

Yazid_0-1718118550340.png

 

Note that the blue line is the current Cumulative fonction which still take the entire period of time.

 

Here below its DAX code:

Yazid_1-1718118714696.png

Digging the values, your formula do not perform a cumulative sum , have a look here below:

Yazid_0-1718120488052.png

Here below is the structure of the columns in question:

Yazid_0-1718119070786.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors