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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
wotkara
Frequent Visitor

If statement returns value based on 3 criterias

Good evening, struggling with this and have spent a week reading books/searching post/watching youtube & cannot figure it out. Please help.

 

Here are my relationship tables:

 

delivery_ticket_detail

 

DTItemQuantityI TypeDelivery DateOriginal Rental Start DateRental Stop DateReturn Date
58160217671R4/30/20244/30/2024  

 

inventory

 

Inventory Item IDItem Last StatusTotal Inventory ObsoleteTotal On Hand ObsoleteTotal Out ObsoleteItem Default Billing Logic ItypeItem Last Return Date
21767Out On MCT58160101R3/19/2024
WOT-RP040Updated qty101R5/1/2024

 

Work Order

AssetWork OrderStatus
WOT-RP04056710Open

 

I want to add a conditional column for CURRENT STATUS that contains a DAX stmt that says "if total out obsolete > 0 then return whichever is true

DT from delivery ticket detail with MAX(delivery date) where return date is blank

OR

Work Order from work order detail if status = Open

 

*It cannot be true for both*

 

ITEMCURRENT STATUS
21767on DT 58160
WOT-RP040on Work Order 56710
1 ACCEPTED SOLUTION
v-jialongy-msft
Community Support
Community Support

Hi @wotkara

 

Please try the following dax:

Create a Measure to Determine the Latest Delivery Ticket Detail: 

Latest DT Detail = 
VAR MaxDeliveryDate = CALCULATE(MAX('delivery_ticket_detail'[Delivery Date]), FILTER('delivery_ticket_detail', ISBLANK('delivery_ticket_detail'[Return Date])))
RETURN
IF(
    ISBLANK(MaxDeliveryDate),
    BLANK(),
    CONCATENATE("on DT ", CALCULATE(MAX('delivery_ticket_detail'[DT]), FILTER('delivery_ticket_detail', 'delivery_ticket_detail'[Delivery Date] = MaxDeliveryDate)))
)

Create a Measure for Open Work Order Status: 

Open Work Order Status = 
IF(
    CALCULATE(COUNTROWS('Work Order'),'Work Order'[Status] = "Open") > 0,
    CONCATENATE("on Work Order ", MAX('Work Order'[Work Order])),
    BLANK()
)

Create the Conditional Column for Current Status: 

Current Status = 
IF(
    [Total Out Obsolete] > 0,
    IF(
        NOT(ISBLANK([Latest DT Detail])),
        [Latest DT Detail],
        IF(
            NOT(ISBLANK([Open Work Order Status])),
            [Open Work Order Status],
            BLANK()
        )
    ),
    BLANK()
)

If the above formula doesn't solve your problem, please provide detailed sample pbix file and the results you expect.So that I can help you better. Please remove any sensitive data in advance.

 

 

 

Best Regards,

Jayleny

View solution in original post

1 REPLY 1
v-jialongy-msft
Community Support
Community Support

Hi @wotkara

 

Please try the following dax:

Create a Measure to Determine the Latest Delivery Ticket Detail: 

Latest DT Detail = 
VAR MaxDeliveryDate = CALCULATE(MAX('delivery_ticket_detail'[Delivery Date]), FILTER('delivery_ticket_detail', ISBLANK('delivery_ticket_detail'[Return Date])))
RETURN
IF(
    ISBLANK(MaxDeliveryDate),
    BLANK(),
    CONCATENATE("on DT ", CALCULATE(MAX('delivery_ticket_detail'[DT]), FILTER('delivery_ticket_detail', 'delivery_ticket_detail'[Delivery Date] = MaxDeliveryDate)))
)

Create a Measure for Open Work Order Status: 

Open Work Order Status = 
IF(
    CALCULATE(COUNTROWS('Work Order'),'Work Order'[Status] = "Open") > 0,
    CONCATENATE("on Work Order ", MAX('Work Order'[Work Order])),
    BLANK()
)

Create the Conditional Column for Current Status: 

Current Status = 
IF(
    [Total Out Obsolete] > 0,
    IF(
        NOT(ISBLANK([Latest DT Detail])),
        [Latest DT Detail],
        IF(
            NOT(ISBLANK([Open Work Order Status])),
            [Open Work Order Status],
            BLANK()
        )
    ),
    BLANK()
)

If the above formula doesn't solve your problem, please provide detailed sample pbix file and the results you expect.So that I can help you better. Please remove any sensitive data in advance.

 

 

 

Best Regards,

Jayleny

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors