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 guys! how you doing?
Just got an insight in my dax code, i've been working on the logic of it for a while and i think im getting somewhere, but still need help. I need the code to return the "out" and "available" status correctly for each order, in a way that it will always start with the earliest order then to the oldest. the reult i got for this actual data is right, but it changes when i change the values, getting wrong results, here is an example of the right result i got.:
I have used many calculations and contitions to achieving this result, but the logic is still not complete.
look at the result i get when change the values:
The correct results for this last one would be available, out, available, out, out, available, out, out.
The measure i am using is the "FinalCorrectStatus" you can find it in the file: DistributeStok
The code is:
Hi @ClaudioF ,
Just wanted to follow up if you were able to resolve the issue or you need any assistance?
If you were able to resolve the issue, can you post your solution so that it would benefit other members to reach the solution easily.
Thank You
Hi @ClaudioF ,
Just wanted to follow up if you were able to resolve the issue or you need any assistance?
If you were able to resolve the issue, can you post your solution so that it would benefit other members to reach the solution easily.
Thank You
Hi @ClaudioF ,
Just wanted to follow up if you were able to resolve the issue or you need any assistance?
If you were able to resolve the issue, can you post your solution so that it would benefit other members to reach the solution easily.
Thank You
@ClaudioF , Try using
FinalCorrectStatus =
VAR CurrentItem = SELECTEDVALUE('DB_ORDERS'[Produto])
VAR CurrentOrderNum = SELECTEDVALUE('DB_ORDERS'[Pedido])
VAR StockAvailable =
CALCULATE(
SUM('Table Estoq'[Estoque Real]),
'Table Estoq'[Produto] = CurrentItem
)
VAR OrdersTable =
FILTER(
ALLSELECTED('DB_ORDERS'),
'DB_ORDERS'[Produto] = CurrentItem
)
VAR RunningTotal =
SUMX(
FILTER(
OrdersTable,
'DB_ORDERS'[Pedido] <= CurrentOrderNum
),
'DB_ORDERS'[Quant. Falta]
)
VAR PreviousRunningTotal =
SUMX(
FILTER(
OrdersTable,
'DB_ORDERS'[Pedido] < CurrentOrderNum
),
'DB_ORDERS'[Quant. Falta]
)
RETURN
IF(
ISBLANK(StockAvailable),
"out",
IF(
PreviousRunningTotal < StockAvailable,
IF(
RunningTotal <= StockAvailable,
"available",
"out"
),
"out"
)
)
Proud to be a Super User! |
|
Sorry it didnt work, the result is the same;
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
18 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
25 | |
10 | |
10 | |
9 | |
6 |