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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
sgupta22
Helper II
Helper II

Cumulative totals between slicer dates

Hi everyone,

 

I am currently using the following formula to compute the cumulative total for a field:

Cumulative PBT = CALCULATE([Adjusted PBT], FILTER(ALL('Calendar'), 'Calendar'[Date] <= MAX('Calendar'[Date])))
 
However, this formula computes the cumulative total from the start of the model to the maximum date of the model.  I am also using a slicer for the years.  Is there a way I can compute the cumulative between two selected slicers for instance, between year 2016 and 2020?
 
Thanks
Shashank
1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @sgupta22 

According to your description, you want to calculate the Cumulative total with the year slicer. Right?

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1669947692521.png

(2)I create a calendar date like yours:

vyueyunzhmsft_1-1669947712377.png

(3)Then we can create a measure :

Measure = var _current_date = MAX('Calendar'[Date])
var _min_date = MINX( ALLSELECTED('Calendar') , [Date])
var _t  = FILTER( ALLSELECTED('Table') , 'Table'[Date] <= _current_date && 'Table'[Date] >= _min_date)
return
SUMX(_t , [Value])

(4)Then we put the 'Calendar'[Year] on the slicer visual and the 'Table'[Date], [Measure] on the table visual and then we can meet your need:

vyueyunzhmsft_2-1669947792470.png

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

6 REPLIES 6
v-yueyunzh-msft
Community Support
Community Support

Hi , @sgupta22 

According to your description, you want to calculate the Cumulative total with the year slicer. Right?

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1669947692521.png

(2)I create a calendar date like yours:

vyueyunzhmsft_1-1669947712377.png

(3)Then we can create a measure :

Measure = var _current_date = MAX('Calendar'[Date])
var _min_date = MINX( ALLSELECTED('Calendar') , [Date])
var _t  = FILTER( ALLSELECTED('Table') , 'Table'[Date] <= _current_date && 'Table'[Date] >= _min_date)
return
SUMX(_t , [Value])

(4)Then we put the 'Calendar'[Year] on the slicer visual and the 'Table'[Date], [Measure] on the table visual and then we can meet your need:

vyueyunzhmsft_2-1669947792470.png

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

Hello, Aniya, i have same problem , i do in my report like your example, but i need more explain on my data. Can you help me with this?

Hi Aniya

 

This is perfect.  Thanks a ton!

djurecic
Super User
Super User

Hi @sgupta22 ,

 Are you using that measure in a table or matrix with the year field? Maybe you can post an example of the end goal you are looking for.

djurecic
Super User
Super User

Hi @sgupta22 ,

 That DAX looks good. What tables/fields are you using in your time related slicers? You need to figure out why MAX('Calendar'[Date]) is not being affected by the slicers.

Thanks for the reply!  The slicer is using 'Calendar'[Year].

I guess the max condition is ok but when I combine it with the MIN condition, the formula doesn't seem to work.  For example, I tried to use the following formula, however, it returns the yearly numbers rather than the cumulative total from the minimum date:

 

Cumulative PBT = CALCULATE([Adjusted PBT], FILTER(ALL('Calendar'), 'Calendar'[Date] >= MIN('Calendar'[Date]) && 'Calendar'[Date] <= MAX('Calendar'[Date])))

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.