cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jalaomar
Helper II
Helper II

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, and Sales Analysis Report

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, and Sales Analysis Report

View solution in original post

Thanks! that solved my issue

mussaenda
Resident Rockstar
Resident Rockstar

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 

View solution in original post

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.