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
teflonreis
Frequent Visitor

Remove null in a Calculated Date column

Hello everyone

 

I have a newly set up list or table with little data so far.

Inside it, there is a calculated date column that sadly displays 0 although no dates were given.

Looks like this in Query mode. 35 days is right. Every else column wrong since there are no dates given. 
This Null distorts my KPI (Average number of days distorts close to 0 instead of 35).

 

teflonreis_1-1654090082614.png

 

 

CalculatedColumn =
( DATEDIFF (Table[OrderDate], Table[DeliveryDate], DAY ) )
- INT (
DATEDIFF ( Table[OrderDate], Table[DeliveryDate], DAY ) / 7
) * 2
- IF (
WEEKDAY ( Table[OrderDate] ) < WEEKDAY ( Table[OrderDate] ),
2,
IF (
OR (
WEEKDAY ( Table[DeliveryDate] ) = 7,
WEEKDAY ( Table[OrderDate] ) = 1
),
1,
0
)
)

 

In a row that does not have dates to calculate the difference of, it just displays 0.

How can I adapt it such that

only if both dates are given, it calculates the difference. Else does not calculate anything. And not giving me null by calculating the difference of nulls.

 

Thanks for any hints.

 

 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @teflonreis 

>> only if both dates are given, it calculates the difference. Else does not calculate anything.

Please add if judgment before your calculation statement, 

IF('Table'[OrderDate]<>BLANK() && 'Table'[DeliveryDate]<>BLANK(), your expression)

vxiaotang_0-1654509358848.png

e.g.

vxiaotang_1-1654509711323.png

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @teflonreis 

>> only if both dates are given, it calculates the difference. Else does not calculate anything.

Please add if judgment before your calculation statement, 

IF('Table'[OrderDate]<>BLANK() && 'Table'[DeliveryDate]<>BLANK(), your expression)

vxiaotang_0-1654509358848.png

e.g.

vxiaotang_1-1654509711323.png

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

tamerj1
Super User
Super User

Hi @teflonreis 
Please try

 

CalculatedColumn =
DATEDIFF ( Table[OrderDate], Table[DeliveryDate], DAY )
    - INT ( DATEDIFF ( Table[OrderDate], Table[DeliveryDate], DAY ) / 7 ) * 2
    - IF (
        WEEKDAY ( Table[OrderDate] ) < WEEKDAY ( Table[OrderDate] ),
        2,
        IF (
            OR ( WEEKDAY ( Table[DeliveryDate] ) = 7, WEEKDAY ( Table[OrderDate] ) = 1 ),
            1
        )
    )

By the way, what do you mean by this condition?

1.png

 

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.

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.