cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LalitDatta
Regular Visitor

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
Community Champion
Community Champion

Hey @LalitDatta ,

 

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
Community Champion
Community Champion

Hey @LalitDatta ,

 

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

That worked! Thank you! 

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Get Ready for Power BI Dev Camp

Power BI Dev Camp - June 24th

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors