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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
COMtrac
Advocate I
Advocate I

Replace NULL

I am sure this is something simple I am missing but I can't for like of me solve it.

i have table called INCIDENTS with a column in the table called PROVINCE. within that column there are Multiple entries of Province A , Province B, Province C and so on but it also has a number of entries of NULL.

Objective: Replace all cells with "null" to "unspecified"

 

i followed to introduction video ( I think it was video 1-4 or 1-5 where it Demonstrates how to create a new column in query editor and replace NULL with USA then delete old column that had null and keep new column.

 

I followed these instructions exactly (except for USA of course) but new column still has NULL

 

The query I used was = if 'Incidents' [Province] = null then "Unspecifed" else 'Incidents' [Province]

the above is exact text I typed for query

 

however null still remains in new column..... Am I missing something 

3 ACCEPTED SOLUTIONS
Baskar
Resident Rockstar
Resident Rockstar

Try this one dude.

 

Create new calculated column using DAX.

 

Column =     if (   isblank( 'Incidents' [Province]),  "Unspecifed" ,   'Incidents' [Province])

 

 

This willhelp u if not let me know i will help u 

View solution in original post

MarcelBeug
Community Champion
Community Champion

Alternatively in Power Query you can use Table.TransformColumns, so you don't need a new coumn:

 

= Table.TransformColumns(Source, {"Province", each if _ is null then "unspecified" else _})

Specializing in Power Query Formula Language (M)

View solution in original post

v-ljerr-msft
Employee
Employee

Hi @COMtrac,

 

In addition, have you tried the "Replace Values" option within Query Editor? It should also work.Smiley Happy

 

1. Select the cell value you want to change(select null in this case) in Query Editor.

 

c1.PNG

 

 

2. Click "Replace Values" option under Home tab. Then you should be able to change null to "Unspecified" like below.

 

r1.PNGr2.PNGr3.PNG

 

Regards

View solution in original post

22 REPLIES 22
shashidharahn
New Member

It should be right DAX with closing bracket.

 

Column =     If (   isblank( 'Incidents' [Province]), ) "Unspecifed" ,   'Incidents' [Province])

 

pjandliz
Advocate II
Advocate II

This ended up working for me...

 

= Table.ReplaceValue(#"Add Client name", null, "Not found in Client table", Replacer.ReplaceValue, {"vcClientName"})

 

Note, null is without quotes. 

Anonymous
Not applicable

none of the below mentioned solutions are working for me. I am trying to change the null values from a column whose data type is date.

@Anonymous that would be a new topic for you to create.

Specializing in Power Query Formula Language (M)
Anonymous
Not applicable

None of the mentioned solutions are working for me. I am trying to replace null from a column whose format is date and it is not working.

v-ljerr-msft
Employee
Employee

Hi @COMtrac,

 

In addition, have you tried the "Replace Values" option within Query Editor? It should also work.Smiley Happy

 

1. Select the cell value you want to change(select null in this case) in Query Editor.

 

c1.PNG

 

 

2. Click "Replace Values" option under Home tab. Then you should be able to change null to "Unspecified" like below.

 

r1.PNGr2.PNGr3.PNG

 

Regards

This worked great for me in 2020.

 

using only the word: null

 

Much appreciated

AliceW
Impactful Individual
Impactful Individual

 I can confirm that using the word null does the trick.

AliceW
Impactful Individual
Impactful Individual

Thanks!! I was just leaving the box empty; now that I've written 'null', it works!!

MarcelBeug
Community Champion
Community Champion

Alternatively in Power Query you can use Table.TransformColumns, so you don't need a new coumn:

 

= Table.TransformColumns(Source, {"Province", each if _ is null then "unspecified" else _})

Specializing in Power Query Formula Language (M)

How can I apply the same technic if the data type is decimal? Thank you

Anonymous
Not applicable

Hi MarcelBug

 

Please can you give the steps required to do this please.

 

I have a date type but would like to display a string message if it is NULL. Would that be possible?

 

Thanks

Anonymous
Not applicable

I have same problem whit datetime column, nothing work for date.

I was able to resolve the error using the information I got from the site https://blog.learningtree.com/error-handling-power-query/

Expand the column error and insert another column using the information in this column.

Aply this:

try
(if [DATA PARA DEVOLUÇÃO] >= (DateTime.Date(DateTime.LocalNow())) and [DATA DA DEVOLUÇÃO] = null
then "No Prazo"
else if [DATA PARA DEVOLUÇÃO]<= (DateTime.Date(DateTime.LocalNow())) and [DATA DA DEVOLUÇÃO] = null
then "Atrasado"
else "Devolvido")

Customize expanded (has an icon to the right in the column heading, click there) and insert this:

if [Personalizar.Value]= "Atrasado" then "Atrasado"
else if [Personalizar.Value] ="Devolvido" then "Devolvido"
else "No Prazo"

good luck!!!

Baskar
Resident Rockstar
Resident Rockstar

Try this one dude.

 

Create new calculated column using DAX.

 

Column =     if (   isblank( 'Incidents' [Province]),  "Unspecifed" ,   'Incidents' [Province])

 

 

This willhelp u if not let me know i will help u 

Anonymous
Not applicable

THX!

Anonymous
Not applicable

Hi,

 

Does this work in a Custom Column in Direct Query Mode? I keep getting the error "Expression.Error: The name 'isblank' wasn't recognized.  Make sure it's spelled correctly." Please advise.

Anonymous
Not applicable

Hi,

 

Does this work in a Custom Column in Direct Query Mode? I keep getting the error "Expression.Error: The name 'isblank' wasn't recognized.  Make sure it's spelled correctly." Please advise.

hi I want to fill the missing value as "Blanks" in the data so that I can display the list in slicer with one line item as Blanks, so how to fill the blanks with the word "Blanks" 

 

Thank you in advance 

I was having the same problem as I think you are having.

The issue seems to be that the text version of "null" is lowercase.

Here is what I did:

  • Use Format option to set the column values to UPPERCASE
  • Then use Replace Values to change NULL to null

 

It treats NULL as being text, but null as being an actual null value.

so much easier , thank you!

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.