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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Felizzpe
New Member

Calculated column value based on another column and rows

Greetings, 

I'm trying to make a calculated column that shows the production order status based on the status from all other production orders of the same group. (Production orders have groups, so they can be dispached all together after everyone is ready) 

 

I tried everything that I know, but no success. Here is the last DAX code that I've tried: 
Order Status = 

VAR OrderGroup = [Grupo_Faturamento]
VAR Location = "READY FOR DISPATCH"
VAR OrdersThatArentFinished =
CALCULATE(
    COUNTROWS(
        FILTER(
            ProcessoAtualReal, -- production order tables
            ProcessoAtualReal[Grupo_Faturamento] = OrderGroup --producton order groups of dispatch
            && ProcessoAtualReal[Processo_Atual_Desc] <> Location --production order location name, like "READY FOR DISPATCH"
        )
    )
) > 0

RETURN
IF( --cheking if there is procution order without grup, is this case, leave it blank
    ISBLANK( OrderGroup ),
    BLANK(),
    IF(
        OrdersThatArentFinished,
        "NOTREADY",
        "READY FOR DISPACH"
    )
)


Here is the result that I'm looking for: 
If all orders are ready, the status should be "ready for dispatch", If one of the orders on the same group isn't ready, the status should be "not ready" for all orders of the same group, since they need to be dispatched together: 

Production OrderLocationOrder GroupOrder Status
1Finished5100Not Ready Since PO Nº 4 is not finished yet.
2Finished5100Not Ready Since PO Nº 4 is not finished yet.
3Finished5100Not Ready Since PO Nº 4 is not finished yet.
4Painting5100Not Ready Since PO Nº 4 is not finished yet.
5Finished6200ready for dispatch
6Finished6200ready for dispatch
7Finished6200ready for dispatch
8Finished6200ready for dispatch
9Finished6200ready for dispatch
10Finished6200ready for dispatch

Anyone knows if this is possible? 

Thanks in advance!!
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Felizzpe ,

 

try like:

column =

VAR _list =

CALCULATETABLE(

    VALUES(data[Location]),

    ALLEXCEPT(data, data[Order Group])

)

VAR _result =

IF(_list = "Finished", "Ready", "Not ready")

RETURN _result

View solution in original post

2 REPLIES 2
Sahir_Maharaj
Super User
Super User

Hello @Felizzpe,

 

Can you please try this approach:

Order Status = 
VAR CurrentGroup = ProcessoAtualReal[Grupo_Faturamento]
VAR IsAnyOrderNotReady =
    CALCULATE(
        COUNTROWS(
            FILTER(
                ProcessoAtualReal,
                ProcessoAtualReal[Grupo_Faturamento] = CurrentGroup &&
                ProcessoAtualReal[Processo_Atual_Desc] <> "READY FOR DISPATCH"
            )
        )
    ) > 0
RETURN
IF(
    ISBLANK(CurrentGroup),
    BLANK(),
    IF(
        IsAnyOrderNotReady,
        "NOT READY",
        "READY FOR DISPATCH"
    )
)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning
FreemanZ
Super User
Super User

hi @Felizzpe ,

 

try like:

column =

VAR _list =

CALCULATETABLE(

    VALUES(data[Location]),

    ALLEXCEPT(data, data[Order Group])

)

VAR _result =

IF(_list = "Finished", "Ready", "Not ready")

RETURN _result

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.