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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
tpoltorak
Helper I
Helper I

Need help with Running Total

I am struggling to understand how to calculate a running total.  I have a columns with customer IDs, week numbers and a number of sessions per week. I would like to calculate a running total of the number of sessions per customer.

What I've done so far is

RT Sessions = CALCULATE(sum(Query1[Sessions]),filter(all(Query1[concat sessions]),Query1[concat sessions]<=MAX(Query1[concat sessions])))

Sessions is the count of sessions per week. Concat sessions is the week numbers. As it is, it's just giving me the number of sessions each week, but I need this to be running total.

Sorry, I am very new to DAX and Power BI.

10 REPLIES 10
tpoltorak
Helper I
Helper I

I am really sorry, but I am still struggling to understand the code for Running Total. I have tried several YouTube videos and code but none of it works.  In the following example, can you please tell me, what is the correct code to calculate the running total of Sessions per ID?
Untitled.png

amitchandak
Super User
Super User

@tpoltorak  , Try like

 

RT Sessions = CALCULATE(sum(Query1[Sessions]),filter(all(Query1) ,Query1[concat sessions]<=MAX(Query1[concat sessions]) && Query1[customer] =max(Query1[customer] )))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

When you are saying Query1[customer] do you mean customer ID's? Then selecting a max customer ID doesn't make sense in my head. Sorry. 🙂

@tpoltorak , Yes. I was not sure about the column name. I want that work within the same customer ID

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

So, wouldn't the line 

Query1[customerID] =max(Query1[customerID]

attempt to select the maximum customer ID? 

@tpoltorak , If you will use customer ID in visual for running total inside a customer, it will take customer from the context.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Untitled.png

@tpoltorak , refer this

https://blog.crossjoin.co.uk/2020/01/20/visual-has-exceeded-the-available-resources-error-power-bi/

 

also, Please share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

This is a sample of data where RT sessions is the desired result

 

 

concat sessions Account Sessions RT Sessions
202050              A001       1            1
202051              A001       4            5
202052              A001       2            7
202101              A001       6           13
202102              A001       1           14
202050              A002       1           1
202051              A002       0           1
202052              A002       0           1
202101              A002       0           1
202102              A002       0           1


Thank you so much for helping me.

Hope this measure is what you want

jameszhang0805_0-1615606437012.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.