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.
Hello again, its been a long month i am tring to find the problem in my code but i have no idea of whats going on.
If anyone can help me with this it would be so good.
I have two dashboards, both have the same code, the thing is, one is working with an excel file as source and the other has an internal source, i dont know if thats the problem root but thats the only difference between them.
The dashboards: not working (ControleDaProducaoMaisLeve&BALSendDistribui.pbix) using excel source
Working well (Sum interval considering many filters11101.pbix) own source
the logic is, the stock might be distribuited to the orders in a way that it priorizes the orders with the lowest value (number) and if the item in the order has a value bigger than the remmaing stock (after being distributed to the orders that the quantity needed is <= to the stock) then, this orders will not be considered and other order with the item will be tested..
Thankyou all.
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 ,
To confirm if the issue is related to the source, you can export the data from the internal source to an Excel file and use it in a non-working dashboard, then see if the issue persists.
You can also:
Check that the field types (numeric, text, date, etc.) are the same in both the Excel source and the internal source; there may be null values or formatting irregularities in Excel.
Confirm that the table relationships and sorting rules in the two data models are identical.
If you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
@Anonymous Thankyou for yout repply, i just found the problem, that was wiht the logic, when running if the value of the item was bigger than the available stock, then the logic worked, but, when the quantity was smaller than the stock but the stock was allready used, the logic summed and then keeps summing.. still trying to find the solution
Hi @ClaudioF ,
Thank you for reaching out to Microsoft Fabric Community.
Thank you @Anonymous for the prompt response.
It sounds like the core issue here isn't the data source, but how the DAX logic is handling stock depletion across filtered orders. You're right in identifying that even after stock is exhausted, the DAX measure continues to evaluate orders as if stock is still available which results in incorrect behavior.
What’s Going Wrong:
DAX measures don’t maintain row-by-row “state” like procedural code. So something like this:
CALCULATE (
SUM ( Orders[Quantity] ),
FILTER ( Orders, Orders[Quantity] <= [RemainingStock] )
)
doesn’t subtract quantities across rows, it just filters based on a static condition.
Here's some steps to fix it:
1. Rank the Orders
Assign a rank based on order priority (Order Number or Date).
OrderRank = RANKX(ALL(Orders), Orders[OrderDate], , ASC, DENSE)
2. Calculate Cumulative Demand
In a calculated column, add up the quantities of all prior orders.
CumulativeDemand =
CALCULATE (
SUM ( Orders[Quantity] ),
FILTER (
Orders,
Orders[OrderRank] <= EARLIER ( Orders[OrderRank] )
)
)
3. Determine If Stock Is Allocated
Only allocate if the cumulative demand is still within available stock.
IsAllocated =
IF ( Orders[CumulativeDemand] <= [TotalAvailableStock], 1, 0 )
You can then filter or sum orders with IsAllocated = 1 to get correct fulfillment values.
If the logic gets messy in DAX, this is actually easier to handle in Power Query with a grouped table and a running total column that lets you stop allocation once stock is exhausted.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate 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 other community members with similar problems can find a solution 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.
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
10 | |
6 |