Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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;
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |