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
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] )))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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
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!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.