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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jeeviscarozza
Regular Visitor

Running Total by Lot Number

Hi! I am trying to get a running total of our items we have in stock for each item, by adding up the quantity of each consecutive lot. Each item has multiple lots. The product lot number column indicates the lot number, the qty is the quantity. I am getting an error that the quantity cant be used. Each item has a specific quantity in each lot, and I want to add these quantitites. This is my code. Any help?
 
running totalattempt =
var currentrank = RANKX(ALL('Reno On Hand Inventory'[Product lot number]), [Qty], , DESC, Dense)
var result = CALCULATE([Qty],
    FILTER(ALL('Reno On Hand Inventory'[Product lot number]),
        RANKX(ALL('Reno On Hand Inventory'[Product lot number]), [Qty], , DESC, Dense) <= currentrank
    )
)
return result
5 REPLIES 5
parry2k
Super User
Super User

@jeeviscarozza you can easily leverage new WINDOW functions, check this video 

 

https://youtu.be/VvPcPaVx64A

 

https://youtu.be/ukZJGUhsXY8

 

👉 Learn Power BI and Fabric - subscribe to our YT channel - @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤️



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

jeeviscarozza
Regular Visitor

Here you go

Lot Expiration DateProduct lot numberQtyLot Expiration DateProduct item numberIntended Output
30-Nov-241341201841030-Nov-24134110
30-Nov-241341201641030-Nov-24134120
30-Nov-241341201621030-Nov-24134130
30-Nov-241341201651030-Nov-24134140
30-Nov-241341201661030-Nov-24134150
30-Nov-241341201671030-Nov-24134160
30-Nov-2413412017310030-Nov-241341160
30-Nov-241341201831030-Nov-241341170
30-Nov-241341201631030-Nov-241341180
30-Nov-241341201851030-Nov-241341190
parry2k
Super User
Super User

@jeeviscarozza could you please post the sample data with the expected output.

 

👉 Learn Power BI and Fabric - subscribe to our YT channel - @PowerBIHowTo



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

jeeviscarozza_0-1691422227260.pngI am trying to get the running total of the quantity. For example, for this item it should be 10, then 20, then 30, etc. As a bonus, I want this calculation to stop when it reaches the quantitiy needed, which is 240.

jeeviscarozza_1-1691422243438.png

 

Hi,

Share data in a format that can be pasted in an MS Excel file and show the expected result.


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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.