Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi All,
I'm still trying to find my way in PowerBi and to solve some interesting questions, which I have.
I have this query that generates the upper table: it put some expected mutations for a specific item no. in a time line and checks whether theoretticaly the stock is not sufficient. So this is nice, but now I want to see what my options are if the stock is not sufficient for the expected mutation:
Can someone tell me how to add such a conditional column? So for 'Previous_purchase' I would like to check if the column 'type' has the value 'Purchase' on the previous row and if so, I woulde like to get the Reference and put it in the column 'Previous_purchase'. If the column 'type' has not the value 'Purchase' on the previous row, then I would like in 'Previous_purchase' to repeat the value of the previous row.
If I'm able to make such an overview, I only have to look at the row with the negative stock after mutation, and I can see directly which Purchase Order(s) are involved.
I hope you can help me out, thanks in advance!
I'm working with swicht and nesteds IF's, but I guess I have to start with getting the value of 'reference' for the row direct after a Purchase row: I've tried and googled a while, and came up with the code below, but it's not working.
previous_purchase = VAR CurrentRowType = Todays_future[type] VAR PreviousRowType = CALCULATE(MAX(Todays_future[type]), FILTER(ALL(Todays_future), Todays_future[index] = EARLIER(Todays_future[index]) - 1)) RETURN IF(CurrentRowType = "Purchase (PO)", Todays_future[reference], BLANK())
Try not to use EARLIER. Use variables instead.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information or anything not related to the issue or question.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...
Hi, thank you for the swift reaction. Variables is competely new to me, so I really hope you can help me a little further. I've created a small dataset in an CSV-file and made it available from my Dropbox account:
I've created an Excelsheet with the desired results:
If I have the extra columns, in my Dashboard I can filter on rows that have in the column 'Stock_after_booking' a value < 0. By doing this I isolate all my project which have a potential problem and I also see which Purchase Orders I can try to influence in order to solve the problem.
I really hope you can help me with this, thanks in advance for your reply!
Kind regards, Daniel
Thank you for the sample data. Looking at it I don't see any fields that would be impacted by user filter choices. As such the new columns could be added in Power Query instead of DAX. Do you have any preferences?
Hi lbendlin, I've extended the dataset with 2 more article numbers: the idea that the stock mutations over time are evaluated per article number, but after looking at the sample data again I wasn't sure that this was clear with the limited data sample. I think it is more clear this way.
I'm a bit lost as to what you are trying to achieve. Are you trying to predict when you run out of stock?
Your sample data may not be sufficient for the scenario.
Hi lbendlin, can you tell me whether it is technically possible? Or do I need more, additional data? I'm still hoping you can help me out.
Keep in mind that Power BI is a reporting tool, not a stock/inventory management application. May want to use a proper app.
Yes I am. We have 4 types of mutations that influence the stock level:
My idea is
I hope you have an idea now of what I try to achieve
Hi lbendlin, PowerQuery would be fine as wel!! I don't have any preferences and am already very happy that you are putting your time and effort in it
There are a couple of tools at your disposal. Read about nested IFs, SWITCH, and COALESCE. Pick whatever you like best.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
12 | |
10 | |
10 | |
6 |