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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
kongyuancn
Helper I
Helper I

Sum for any period

Hi there,

I have a small table like this:

 

kongyuancn_0-1625026459163.png

And I want to calculate sum of all previous date. I created a calculated column:

TotalTillThisDate = CALCULATE(SUMX('Table','Table'[Quantity]),FILTER('Table','Table'[Date]<=EARLIER('Table'[Date])))

Then it looks like this:

kongyuancn_1-1625026596770.pngkongyuancn_2-1625026617935.png

 

Everything looks fine. But when I want to add a slicer to show a small period, for example, 1/2-1/4, it looks like as following:

kongyuancn_4-1625026800708.png

The first number 5 is sum of 1/1 and 1/2. This is NOT wha I want (I don't want 1/1 data calculated in this chart). How to make the data strictly limited to the slicer limits? (In this example, I want to get 3, 8, 11 when I set slicer from 1/2 to 1/4)

 

Thanks in advance.


 

 

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Picture1.png

 

https://www.dropbox.com/s/oc067783ze89yrr/kongyuan.pbix?dl=0 

 

 

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.


Go to My LinkedIn Page


View solution in original post

ryan_mayu
Super User
Super User

@kongyuancn 

if you don't have a date table,you can try this

Measure = 
VAR _min= CALCULATE(min('Table'[Date]),ALLSELECTED('Table'[Date]))
VAR _max= max('Table'[Date])
return CALCULATE(SUM('Table'[Quantity]),FILTER(ALL('Table'),'Table'[Date]>=_min&&'Table'[Date]<=_max))




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

Proud to be a Super User!




View solution in original post

5 REPLIES 5
ryan_mayu
Super User
Super User

@kongyuancn 

if you don't have a date table,you can try this

Measure = 
VAR _min= CALCULATE(min('Table'[Date]),ALLSELECTED('Table'[Date]))
VAR _max= max('Table'[Date])
return CALCULATE(SUM('Table'[Quantity]),FILTER(ALL('Table'),'Table'[Date]>=_min&&'Table'[Date]<=_max))




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

Proud to be a Super User!




Thank you @ryan_mayu . That's exactly what I want.

you are welcome





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

Proud to be a Super User!




Jihwan_Kim
Super User
Super User

Picture1.png

 

https://www.dropbox.com/s/oc067783ze89yrr/kongyuan.pbix?dl=0 

 

 

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.


Go to My LinkedIn Page


Thank you @Jihwan_Kim That's exact what I want.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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