Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ClaudioF
Helper II
Helper II

cant find the problem in code

Hi everybody

This porblem is driving me crazy, i have two dashboards with the same dax codes, the thing is, in one it works properly, in the other it does not and i just can't find out why. the dashboards: the one with problem (ControleDaProducaoMaisLeve&BALSendDistribui.pbix) the working one (Sum interval considering many filters11101.pbix)

The logic is, the stock might be distributed properly through the orders in a whay that it goes first to the oldest to the newest order, and if the order quantity is bigger than the left stock after distributed to the anterior, it will verify the next order and if the quantity os the remaing stock is enought to the order need, it will be used. see in image below:

 

Captura de tela 2025-03-06 200914.png

 

the marked in green is what it should be, i have 72 of this item in stock and it should be enought to the orders 111, 222, 444 and 555.

 

Please anyone help me, i totaly can't find the problem, one works and the other just does not..

 

 

Thankyou all.

6 REPLIES 6
ClaudioF
Helper II
Helper II

Just to add info, i have just tried some tests and, i am not sure, but it seems that when i work with a external data source or and excel file, the result was wrong, i dont know if its even possible that something like that caan interfer in the result, i just ajusted all the columns with its correct data type.. i still dont know what difference between the two dashboards is cousing the problem..

HI @ClaudioF 

Thank you for reaching out to the Microsoft Fabric Forum Community.


As you said your are using external data source or and excel file, is your isuue got resolved with that? or still your facing the issue, let us know we will try to resolve the issue.

Thanks.

Hi @ClaudioF 

I hope the information provided was helpful. If you still have questions, please don't hesitate to reach out to the community.

 

Hi @ClaudioF 
I hope everything is going well on your side. We haven't received a response from you yet. If the issue still persists, please share the sample data. If you have any other concerns, feel free to reach out to the community.

Anonymous
Not applicable

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"
    )

vcgaomsft_0-1741315500856.png

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

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?

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.