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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
sloane
Frequent Visitor

Need Help with Filters on a running sum

Hi everyone, 

 

I have a table that looks something like this;PBI.PNG

 and I want to be able to create a running total of the amount column and have two slicers controlling the output.

The first slicer is country which shows only the states in the country when triggered 

the second slicer (where the magic happens) is for state, and gives the sum for the respective state

 

My current formula (below) only returns the sum on a country level but not a state level

 

 

Amount Targeted = 
VAR endOfPeriod = MAX ( 'Calendar'[Date] )

VAR startOfPeriod = MIN( 'Calendar'[Date] )

RETURN
    CALCULATE (
        SUM(Table[amount]),
        FILTER (
            ALL(Table),
               ( Table[Date] <= endOfPeriod
                         
        )
    ))

 

 

 Thank you in advance for your help 🙂 

1 ACCEPTED SOLUTION

Hi @sloane ,

 

Create a measure as below:

 

Measure = IF(ISFILTERED('Table'[State]),
 CALCULATE(SUM('Table'[Amount]),FILTER(ALLSELECTED('Table'),'Table'[Date]<=MAX('Table'[Date])&&'Table'[State]=SELECTEDVALUE('Table'[State]))),
 CALCULATE(SUM('Table'[Amount]),FILTER(ALLSELECTED('Table'),'Table'[Date]<=MAX('Table'[Date]))))

 

And you will see:

v-kelly-msft_0-1613542999684.png

 

v-kelly-msft_1-1613543009140.png

v-kelly-msft_2-1613543016758.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@sloane , Try like

Amount Targeted =

CALCULATE (
SUM(Table[amount]),
FILTER (
ALLSELECTED(Table),
( Table[Date] <= max(Table[Date])

)
))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks but this still doesnt work when I filter the state slicer. It only works when I filter the country slicer

Hi @sloane ,

 

Create a measure as below:

 

Measure = IF(ISFILTERED('Table'[State]),
 CALCULATE(SUM('Table'[Amount]),FILTER(ALLSELECTED('Table'),'Table'[Date]<=MAX('Table'[Date])&&'Table'[State]=SELECTEDVALUE('Table'[State]))),
 CALCULATE(SUM('Table'[Amount]),FILTER(ALLSELECTED('Table'),'Table'[Date]<=MAX('Table'[Date]))))

 

And you will see:

v-kelly-msft_0-1613542999684.png

 

v-kelly-msft_1-1613543009140.png

v-kelly-msft_2-1613543016758.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.