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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
davegw
Frequent Visitor

Running Total Problem

I have a data set with counts per number of weeks before a certain date. I want to visualsie this as a running total.

 

I'm using this as my measure:-

 

tickets running total in weeks_before 2 =
CALCULATE(
    SUM('sales_over_time (2)'[tickets]),
    FILTER(
        ALLSELECTED('sales_over_time (2)'[weeks_before]),
        ISONORAFTER('sales_over_time (2)'[weeks_before], MAX('sales_over_time (2)'[weeks_before]), ASC)
    )
)

 

My result is only partially correct, it looks like the picture below. The problem is the currently selected data (from slicers) contains no records for weeks 29 to 52 but these week numbers exist for rows that are filtered out by the slicer. This seems to be causing an error in the calculation. What am I missing?

running.png

 

1 ACCEPTED SOLUTION
Cmcmahan
Resident Rockstar
Resident Rockstar

It is working correctly.  When you use ALLSELECTED in your measure, it only returns values that are available to the current visual.  Since you have filtered data from weeks 29-52 via slicer, the data isn't used.

 

You can try replacing ALLSELECTED with ALL or ALLEXCEPT, though you may have to reapply other filters as necessary.

tickets running total in weeks_before 2 =
CALCULATE(
    SUM('sales_over_time (2)'[tickets]),
    FILTER(
        ALLEXCEPT('sales_over_time (2)', 'sales_over_time (2)'[weeks_before]),
        ISONORAFTER('sales_over_time (2)'[weeks_before], MAX('sales_over_time (2)'[weeks_before]), ASC)
    )
)

View solution in original post

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @davegw ,

Have you solved the problem?

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

If you still need help, please share some data sample and your desired output so that we could help further on it.

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cmcmahan
Resident Rockstar
Resident Rockstar

It is working correctly.  When you use ALLSELECTED in your measure, it only returns values that are available to the current visual.  Since you have filtered data from weeks 29-52 via slicer, the data isn't used.

 

You can try replacing ALLSELECTED with ALL or ALLEXCEPT, though you may have to reapply other filters as necessary.

tickets running total in weeks_before 2 =
CALCULATE(
    SUM('sales_over_time (2)'[tickets]),
    FILTER(
        ALLEXCEPT('sales_over_time (2)', 'sales_over_time (2)'[weeks_before]),
        ISONORAFTER('sales_over_time (2)'[weeks_before], MAX('sales_over_time (2)'[weeks_before]), ASC)
    )
)

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors