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
Anonymous
Not applicable

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

 

1 ACCEPTED SOLUTION
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


View solution in original post

6 REPLIES 6
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


az38
Community Champion
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

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
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
Community Champion
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


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

DeliveryDate = "" maybe causing issue here.

 

PowerBI__Dax_comparison.png

az38
Community Champion
Community Champion

well, @Anonymous 

try to debug isblank.

create two columns

= if(isblank([OrderDate]),1,-1)
= if(isblank([DeliveryDate]),1,-1)

if you can you could share your pbix-file to watch closely

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


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

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.