cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Anonymous
Not applicable

## What is the most efficient way to get running total based on two columns?

Say I have the following table(I will call it 'Schools'):

 School Week Pickups Harbor Elementary 1 43 Harbor Elementary 2 21 Harbor Elementary 3 65 Harbor Elementary 4 34 Sinclair Elementary 1 24 Sinclair Elementary 2 16

I want to see if I could create a 'running total' column(or measure if that's easier) based on the 'School' and 'Weeks' column, so it would look something like this:

 School Week Pickups Running Total Pickups Harbor Elementary 1 43 43 Harbor Elementary 2 21 64 Harbor Elementary 3 65 129 Harbor Elementary 4 34 163 Sinclair Elementary 1 24 24 Sinclair Elementary 2 16 40

How would I go about doing that?

1 ACCEPTED SOLUTION
Super User

Hey @Anonymous ,

try the following measure, that should do it:

``````Running Total Pickups =
VAR vLastWeek = MAX( Schools[Week] )
RETURN
CALCULATE(
SUM( Schools[Pickups] ),
Schools[Week] <= vLastWeek
)``````

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

2 REPLIES 2
Super User

Hey @Anonymous ,

try the following measure, that should do it:

``````Running Total Pickups =
VAR vLastWeek = MAX( Schools[Week] )
RETURN
CALCULATE(
SUM( Schools[Pickups] ),
Schools[Week] <= vLastWeek
)``````

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Anonymous
Not applicable

That worked! Thank you!