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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Drobinson1
Helper III
Helper III

Running balance total

I have a current inventory quantity and wanted to be able to calculate balances throughout time based on historical movement quantities.

 

In this example I know the current starting quantity of 7.  I also know all of the movements since a certain archive point.

 

I would like to calculate the ending/starting balance.  Again all I have is the current balance on hand as of right now and three columns of part code/date/ic_move_quantity.

 

I want to calculate the starting and ending balances after each ransaction.

 

to do this I think I need to find what the most recent transation was and go backwards from there.   I am using direct query and can' figure out how to do this since I can't use variables and calcualte in a column.

 

 

 

Part CodeDateIc_Move_QuantityStarting BalanceEnding
BUMESPEP10/20/2017-961037
BUMESPEP10/19/2017-25128103
BUMESPEP10/18/20171280 

 

3 REPLIES 3
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @Drobinson1,

You can not create measure or calculated column when you are using direct query, I personally suggest you use import mode. And just import the necessary data. Then create measure as the @Ashish_Mathur posted. Please feel free to ask if you have any other issue.

Best Regards,
Angelia

Ashish_Mathur
Super User
Super User

Hi @Drobinson1,

 

You may refeer to my solution in this workbook.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Take a look at this:

 

http://www.daxpatterns.com/cumulative-total/

 

These starting and ending values can be calculates as measures.

 

I would caution using DirectQuery.  Do you need the near-realtime capability?  The performance will likely suffer, and you're right, you don't get to use many of DAX's more powerful functions.

 

https://www.sqlbi.com/tv/directquery-in-analysis-services-best-practices-performance-use-cases/ 

Marco Russo speaks about how and when to use DirectQuery.  Maybe you'd be better off with a Live Connection instead?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors