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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jalaomar
Helper IV
Helper IV

Power query if statement

Hi all,

 

I need to create some custom columns and was wondering if someone can help with how to handle dates with null value 

 

my custom column is calculating the difference of days between two dates, how can i in the expression translate null to blank (no value) as it will impact my other custom columns 

i tried to find if statement but power query didn't seem to find it .....

2021-09-30_08-48-41.png

2 ACCEPTED SOLUTIONS

Hi, that was a mistake 

 

but how do i remove the null and just leave the row blank?

 

I will create another Conditional column that will state if VSU Days <= 35 days then 1 else 0 

and the null value will create an error 

View solution in original post

Tahreem24
Super User
Super User

@jalaomar ,Instead NULL() you should enter in else part as double quotes like  " ". So it will create blank value.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

5 REPLIES 5
Tahreem24
Super User
Super User

@jalaomar ,Instead NULL() you should enter in else part as double quotes like  " ". So it will create blank value.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Thanks! that solved my issue

mussaenda
Super User
Super User

Hi @jalaomar ,

 

Reading your concern, I am h aving no idea why ITG3 is having a box though it is not on the formula.

You can do like 

if [#"ITG4#(lf)Actual"] = null 
or [#"IMS3.1#(lf)Actual"] = null
then null 
else 
Duration.Days([#"ITG4#(lf)Actual"] - [#"IMS3.1#(lf)Actual"])

Hi, that was a mistake 

 

but how do i remove the null and just leave the row blank?

 

I will create another Conditional column that will state if VSU Days <= 35 days then 1 else 0 

and the null value will create an error 

Hi @jalaomar ,

 

In that case, you can do two options:

first is 

 

if [VSU Days] = null 
then 0
else 
if [VSU Days] <= 35
then 1
else 
0

 

the second is 

try
if [VSU Days] <= 35
then 1 
else 
0
otherwise 
0

 

Basically the formula is turning your null to 0 instead of creating error

 

Hope this helps

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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