Running Total

pociners

New Member
Joined
Mar 19, 2014
Messages
32
Hi Everyone,

I'm very new in PowerPivot and wanna ask something,
I have this table
21dobvd.jpg

and i create a calculation using this formula:
Running Total:=CALCULATE(SUM([Value]),FILTER(ALL(Table1[YearWeek]),[YearWeek]<=MAX([YearWeek])))

and indeed i can "running total" through YearWeek:
2iia5cg.jpg


but if I "running total" through Year AND Week, the result is like this:
214e6fk.jpg


Can anybody help me? so if I "running total" through Year AND Week the result will be the same with "running total" through YearWeek.

Sorry for my bad english,

Thanks:)
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi pociners,

The problem is that FILTER( ALL(Table1[YearWeek]) ...) filters all values of YearWeek ignoring the filter context, but the filters on columns Year and Week remain.

Ideally, you should create a 'calendar' table (whether it is daily, weekly or whatever) that is separate from your fact table.
Your fact table should then be related to the key column of that table (looks like the key is YearWeek in your example).

Then you can use a formula that filters the entire Calendar table to compute the running total, like:
Code:
[B]Running Total :=[/B]
CALCULATE (
    SUM ( Table1[Value] ),
    FILTER ( ALL ( Calendar ), Calendar[YearWeek] <= MAX ( Calendar[YearWeek] ) )
)

(If the Calendar table key is Date, you can mark it as a Date Table and get away with FILTER ( ALL ( Calendar[Date] ) ... ), see here: Time Intelligence in Power BI Desktop - SQLBI )

However, if we stick with the table as in your example, you can achieve the same result with a more awkward formula:
Code:
[B]Running Total :=[/B]
CALCULATE (
    SUM ( Table1[Value] ),
    FILTER ( ALL ( Table1[Year], Table1[Week], Table1[YearWeek] ), Table1[YearWeek] <= MAX ( Table1[YearWeek] ) )
)
 
Upvote 0
Hi pociners,

The problem is that FILTER( ALL(Table1[YearWeek]) ...) filters all values of YearWeek ignoring the filter context, but the filters on columns Year and Week remain.

Ideally, you should create a 'calendar' table (whether it is daily, weekly or whatever) that is separate from your fact table.
Your fact table should then be related to the key column of that table (looks like the key is YearWeek in your example).

Then you can use a formula that filters the entire Calendar table to compute the running total, like:
Code:
[B]Running Total :=[/B]
CALCULATE (
    SUM ( Table1[Value] ),
    FILTER ( ALL ( Calendar ), Calendar[YearWeek] <= MAX ( Calendar[YearWeek] ) )
)

(If the Calendar table key is Date, you can mark it as a Date Table and get away with FILTER ( ALL ( Calendar[Date] ) ... ), see here: Time Intelligence in Power BI Desktop - SQLBI )

However, if we stick with the table as in your example, you can achieve the same result with a more awkward formula:
Code:
[B]Running Total :=[/B]
CALCULATE (
    SUM ( Table1[Value] ),
    FILTER ( ALL ( Table1[Year], Table1[Week], Table1[YearWeek] ), Table1[YearWeek] <= MAX ( Table1[YearWeek] ) )
)


Aaaahhh Thank you, your 2nd formula works very well,
Well, Actually i have a separate table and related to my fact table, but when i run your first formula, it always goes wrong.
I think your 2nd formula is enough for me.
Thanks btw..
 
Upvote 0

Forum statistics

Threads
1,224,155
Messages
6,176,736
Members
452,741
Latest member
Muhammad Nasir Mahmood

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top