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
LanceTDL
Frequent Visitor

Running Total based on a Seperate Value

Hello All, 

I am a new user to Power BI, I am familiar with SQL, but still learning DAX. I am struggling to find any answers on the issue I am having. I have transactional data in SQL that I have connected to Power BI, my issue is the data doesn't contain the daily values, for this example daily qty on hand. What I want to have is either a column or measure of what the daily qty on hand was . The data I have is the current value qty on hand (as of today) and all the transactional history the items. 

These are stored in two different but related tables 

ItemQty on Hand
XYZ10




ItemTransactional QtyDate
XYZ1June 1, 2021
XYZ-1May 17, 2021
XYZ-4May 2, 2021
XYZ3April 30, 2021
XYZ2April 23, 2021
XYZ-5April 2, 2021
XYZ-1March 28, 2021
XYZ-1March 18, 2021



How can I generate either a measure or column that would display the date and the running total of qty on hand? Example for June 1, 2021 the Running Qty on hand would = (Qty on hand + transactional qty) in this case 10+1=11

This is an example of what I would like to see:

 

ItemRunning Qty On HandDate
XYZ11June 1, 2021
XYZ10May 17, 2021
XYZ6May 2, 2021
XYZ9April 30, 2021
XYZ11April 23, 2021
XYZ6April 2, 2021
XYZ5March 28, 2021
XYZ4March 18, 2021



Thanks in advance for any assistance. 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @LanceTDL 

Please check the below picture and the sample pbix file's link down below.

 

Picture1.png

 

Running Qty On Hand Measure =
VAR transactioncumulatereverse =
CALCULATE (
SUM ( Transactions[Transactional Qty] ),
FILTER ( ALL ( Dates ), Dates[Date] >= MAX ( Dates[Date] ) )
)
RETURN
IF (
ISFILTERED ( Dates[Date] ),
IF (
NOT ISBLANK ( SUM ( Transactions[Transactional Qty] ) ),
transactioncumulatereverse
+ SUMX ( Transactions, RELATED ( Items[Qty on Hand] ) )
)
)

 

 

https://www.dropbox.com/s/cne3sh5r1mz30ip/lance.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

6 REPLIES 6
Jihwan_Kim
Super User
Super User

Hi, @LanceTDL 

Please check the below picture and the sample pbix file's link down below.

 

Picture1.png

 

Running Qty On Hand Measure =
VAR transactioncumulatereverse =
CALCULATE (
SUM ( Transactions[Transactional Qty] ),
FILTER ( ALL ( Dates ), Dates[Date] >= MAX ( Dates[Date] ) )
)
RETURN
IF (
ISFILTERED ( Dates[Date] ),
IF (
NOT ISBLANK ( SUM ( Transactions[Transactional Qty] ) ),
transactioncumulatereverse
+ SUMX ( Transactions, RELATED ( Items[Qty on Hand] ) )
)
)

 

 

https://www.dropbox.com/s/cne3sh5r1mz30ip/lance.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Is there a modification what would also allow skipped dates to carry the value from before. Basically that the transaction change is 0 for every day between 6/1/21 and 5/17/20 where there are no transactions. 

I am having trouble graphing it since there the dates aren't consistent or all there. I would like to have a Date Hierarcy that I can break down by Year, Qtr, Month, Day of the stock levels. 

Hi, @LanceTDL 

Sorry that I quite do not understand your question.

Please let me know how your desired outcome looks like.

Thanks.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Sorry @Jihwan_Kim I tried to insert a table but I kept getting errors. 

My disered output would be like this: 

Screen Shot 2021-06-08 at 8.08.29 AM.png
etc...

It has the daily value for any given date. 

Hi, @LanceTDL 

I am not 100% sure if I understood your explanation correctly, but please check the link down below.

 

https://www.dropbox.com/s/cne3sh5r1mz30ip/lance.pbix?dl=0 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thanks @Jihwan_Kim 

That was exactly what I was looking for!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors