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.
Hey everyone! how you doing?
I have been now a month trying to make this logic work in dax but no solution.
Cna anyone please help me with this? or even just say that power Bi will not be able of doing it happen?
Here is the thing: I need to distribute evenly the stock of an item throught the orders of this item, in a way that the result is as shown in the table bellow:
I need the stock to be distributed in a way that when its not enought to the order it will try to fit in the other order until the total stock is used. Use the stock amount of 21 for this example, you will see that the ones set as available, when summed will be exactly 21.
The status column is the outcome that i need from the dax code.
This is very hard, i don't even know if its possible; can anyone please helpe me with it?
Thankyou a lot allready.
Hi @ClaudioF,
Thank you for reaching out to the Microsoft fabric community forum. Thank you @techies, for your inputs on this issue.
You're certainly not alone in finding sequential stock allocation logic challenging in DAX, as it is not inherently procedural.
The positive news is that what you're aiming to achieve is feasible in Power BI using a calculated column. Here's the approach that works:
Here’s a simplified version of the DAX formula you can use for a calculated column:
Status =
VAR Stock = 21
VAR CumQty =
CALCULATE (
SUM ( Orders[QtyRequested] ),
FILTER (
Orders,
Orders[OrderID] <= EARLIER ( Orders[OrderID] )
)
)
RETURN
IF ( CumQty <= Stock, "Available", "Not Available" )
Just make sure your table has a proper OrderID or sort column to maintain row order, and you can adjust the stock reference if it comes from another table.
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
Hi @ClaudioF,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
Hi @ClaudioF,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.
Hi @ClaudioF,
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.
Hi @ClaudioF please try this, add as a calculated column
Hi @techies , I can't do as calculated column because I need it to be donamic, when I filter by date for example, it will do the same logic but only with the filtered orders in that visual..
ok , try this
im sorry for the missing information, but the trick of this all is also that this might be distribute to the earliest order then tto the oldest, each of those lines is a order with number, 111, 222, 333, 444, 555, 666, 777, 888, in order...
Hi @ClaudioF as i understand,
Hey there! i just got an update to this problem, look the post: https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conditional-and-selective-sum-with-f...
its an other post i did with more explanig about the problem and the file..
Thankyou
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
12 | |
11 | |
8 | |
6 |