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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
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'):

 

SchoolWeekPickups
Harbor Elementary143
Harbor Elementary221
Harbor Elementary365
Harbor Elementary434
Sinclair Elementary124
Sinclair Elementary216


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:

SchoolWeekPickups Running Total Pickups
Harbor Elementary14343
Harbor Elementary22164
Harbor Elementary365129
Harbor Elementary434163
Sinclair Elementary12424
Sinclair Elementary21640


How would I go about doing that? 



1 ACCEPTED SOLUTION
selimovd
Super User
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
 

 

View solution in original post

2 REPLIES 2
selimovd
Super User
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! 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.