Forum Discussion
cant find the problem in code
Hi ClaudioF ,
Please try:
ItemStatus =
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 RunningStock =
CALCULATE (
SUM ( 'DB_ORDERS'[Quant. Falta] ),
FILTER (
ALLSELECTED ( 'DB_ORDERS' ),
'DB_ORDERS'[Produto] = MAX ( 'DB_ORDERS'[Produto] )
&& 'DB_ORDERS'[Data Limite] <= MAX ( 'DB_ORDERS'[Data Limite] )
)
)
RETURN
IF (
RunningStock <= StockAvailable
&& MAX ( DB_ORDERS[Quant. Falta] ) <= StockAvailable,
"available",
"out"
)
Best Regards,
Gao
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!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
- ClaudioF1 year agoHelper II
Hello Anonymous thankyou for the repply; i tried this code and it works as you showed, alghthou, its considering the date insteat of the order num to determn if the order is older or not, the thing with the date is that there can be many orders with the same date, bust the number of the order will really show which is the the first in line;
Did you see the working dashboard? it totally works with the same dax code, using the same logic, considering the order num, i did the same things to the other dashboard but it didnt work.. what could be the problem?