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
Goodtogo
Regular Visitor

DAX Conditional Lookup According to ID Column

Hi 

I have the data below and looking for DAX to create New_Status column.

 

  • Given Table Name: [Order Table]
Order IDShipping  Status
301255Delivered
301255Not Started
301255Shipped
262022Delivered
262022Shipped
123333Delivered
123333Delivered
201012Not Started
201012Not Started

 

Logic:-

When one order id has a combination of shipping Status:  "Deliverd","Not Started" and "Shipped" THEN " Not Started"

When one order id has a combination of shipping Status:  "Deliverd" and "Shipped" THEN " Shipped"

When one order id has a single  shipping Status:  "Deliverd" THEN " Delivered"

When one order id has a single  shipping Status:  "Not Started" THEN " Not Started"

 

  • Expected result should be based on the above logic giving us results indicated below:
Order IDShipping  StatusNew_Status
301255DeliveredNot Started
301255Not StartedNot Started
301255ShippedNot Started
262022DeliveredShipped
262022ShippedShipped
123333DeliveredDelivered
123333DeliveredDelivered
201012Not StartedNot Started
201012Not StartedNot Started
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Based on the above condition, I tried to create a calculated column like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1664948837636.png

 

 

New_Status CC =
VAR _referencecolumn =
    SUMMARIZE (
        FILTER ( Data, Data[Order ID] = EARLIER ( Data[Order ID] ) ),
        Data[Shipping  Status]
    )
RETURN
    SWITCH (
        TRUE (),
        "Delivered"
            IN _referencecolumn
            && "Not Started"
            IN _referencecolumn
            && "Shipped" IN _referencecolumn, "Not Started",
        "Delivered"
            IN _referencecolumn
            && "Shipped" IN _referencecolumn, "Shipped",
        "Delivered" IN _referencecolumn, "Delivered",
        "Not Started" IN _referencecolumn, "Not Started"
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Based on the above condition, I tried to create a calculated column like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1664948837636.png

 

 

New_Status CC =
VAR _referencecolumn =
    SUMMARIZE (
        FILTER ( Data, Data[Order ID] = EARLIER ( Data[Order ID] ) ),
        Data[Shipping  Status]
    )
RETURN
    SWITCH (
        TRUE (),
        "Delivered"
            IN _referencecolumn
            && "Not Started"
            IN _referencecolumn
            && "Shipped" IN _referencecolumn, "Not Started",
        "Delivered"
            IN _referencecolumn
            && "Shipped" IN _referencecolumn, "Shipped",
        "Delivered" IN _referencecolumn, "Delivered",
        "Not Started" IN _referencecolumn, "Not Started"
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

HI @Jihwan_Kim 

Thanks for the solution it works perfectly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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