Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

How to update if statement?

I have CarSales with OrderDate and DeliveryDate.

I'm using following to visialize Car DeliveryStatus with pie chart.
I get values like 30% for "Delivery OK", "Delivery Failed"

date diff = datediff(order_date,delivery_date,day)

DeliveryStatus = if([date diff]>30 ,"Delivery OK" ,"Delivery Failed)

 

Now I would like to add new values pie chart like "Not Delivered Yet",
which happens when OrderDate is not null/Empty and DeliveryDate is Null/Empty.

How to update DAX "DeliveryStatus = if([date diff]>30 ,"Delivery OK" ,"Delivery Failed)"

 

  • Anonymous's avatar
    Anonymous
    6 years ago

    Anonymous 

    Try create a calculated column using this dax:

    DeliveryStatus =
    VAR Status1 =
             IF ( [date diff] > 30, "Delivery OK", "Delivery Failed" )
    RETURN
             IF ([OrderDate] <> BLANK () && [DeliveryDate] = BLANK (),
            "Not Delivered Yet", Status1)


    Best,
    Paul


6 Replies

  • az38's avatar
    az38
    Community Champion

    Hi Anonymous 

    try

    DeliveryStatus = 
    if(
    [date diff]>30 ,"Delivery OK" ,
    (if(not(isblank([OrderDate]) && isblank([DeliveryDate])),"Not Delivered Yet","Delivery Failed")
    )

    do not hesitate to give a kudo to useful posts and mark solutions as solution

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      I never get "Not Delivered Yet "result to statement if(not(isblank([OrderDate]) && isblank([DeliveryDate])) or isblank([DeliveryDate]) even there are clearly black fields for OrderDate and DeliveryDate.

       

      Does "not(isblank([OrderDate])" work with empty dates?

      • az38's avatar
        az38
        Community Champion

        Anonymous 

        try

        DeliveryStatus = 
        if(
        [date diff]>30 ,"Delivery OK" ,
        (if(not(isblank([OrderDate]) && [OrderDate]<>"" && (isblank([DeliveryDate]) || [DeliveryDate]="")),"Not Delivered Yet","Delivery Failed")
        )

        do not hesitate to give a kudo to useful posts and mark solutions as solution

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous 

    Try create a calculated column using this dax:

    DeliveryStatus =
    VAR Status1 =
             IF ( [date diff] > 30, "Delivery OK", "Delivery Failed" )
    RETURN
             IF ([OrderDate] <> BLANK () && [DeliveryDate] = BLANK (),
            "Not Delivered Yet", Status1)


    Best,
    Paul