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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
JoRose
Frequent Visitor

Track Stock amount

Dear DAX/Power BI Community,

I have the following issue. I want to record warehouse stock on a daily basis. To restrict the amount of new entries in the database, i want to record only those products which quantity changed since the last update. The point i am struggeling with is: when i have a product which didnt change in quantity over a few days, it still needs to be counted as in stock with the quantityamount from the last date with a record for the given product.

The data in the Database could look like this:

SampleData.png

 

 

 

 

 

 

 

 

 

 

 

As you can see the ProductID 220 has no entry for the 05.12 which means that its quantity is still 1.

The DAX formula should respect this and evaluate to the following result:

Diagram.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The underlying tabular datamodel looks like this:

Datamodel.png

 

 

 

 

 

 

 

 

 

So what i need is a measure that can deliver the result shown in the diagram. 

Any ideas are highly appreciated. I am really stuck right now.

 

Many thanks for your help and a Merry Christmas to you all!!!

1 ACCEPTED SOLUTION
some_bih
Super User
Super User

Hi @JoRose I created two measure, based on your sample data, as following

Adjust your proper fact / Calendar tables names and you should get output from Output (Date from Date table, not fact)

1. Simple simple = SUM(factInventory[Quantity])

2. Sum adjusted =
IF (
    ISEMPTY ( factInventory ),
    CALCULATE ( [Simple simple] ,OFFSET ( -1,, ORDERBY ( 'Date'[Date] ), ) ),
    [Simple simple]
)

 

Output

some_bih_0-1703254716957.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






View solution in original post

5 REPLIES 5
some_bih
Super User
Super User

Hi @JoRose I created two measure, based on your sample data, as following

Adjust your proper fact / Calendar tables names and you should get output from Output (Date from Date table, not fact)

1. Simple simple = SUM(factInventory[Quantity])

2. Sum adjusted =
IF (
    ISEMPTY ( factInventory ),
    CALCULATE ( [Simple simple] ,OFFSET ( -1,, ORDERBY ( 'Date'[Date] ), ) ),
    [Simple simple]
)

 

Output

some_bih_0-1703254716957.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Track Stock amount

Helo @some_bih, thank you so much for your effort. In my simple example scenario it works perfectly. 

Anyway i still have issues with your solution. It only works when the offset between changes in stock amount are no more then 1 day. To show what i mean, i have slightly adjusted the sample data.

Fact table:

Screenshot 2024-01-08 155107.png

 

Example visual:

Screenshot 2024-01-08 155217_copy.png

 

As you can see, there doesnt seem to be any stock for 220 at the 08. of december, but there are actually still 3 pieces 06. december. 

And finally one more point: I couldnt find a way to sum up the result of the measure 'sum adjusted'.

But in the end i need a visual which only shows one bar per day, whichs means ill have to sum up over all products on that day.

 

I hope you can help me out on that. If there are remaining questions reach out.

 

with kind regards.

Hi @JoRose thank you for reaching. 

I am busy these days, but I will take a look and let you know. I hope you understand.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






some_bih
Super User
Super User

Hi @JoRose what is your request?

You wrote " want to record only those products which quantity changed since the last update." so you want to flag something like calculate / include / exclude... provide expected output in table view (later you can do visuals)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Hey @some_bih, i have updated my post. What i need is a measure that can calculate the result the shown in the diargam.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.