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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
acerNZ
Helper III
Helper III

How to remove #NA globally across all tables

Hi Experts,

Is there a way to remove #NA by replace with "null" across all the tables instead of clicking on each coloumn to replace it

 

Thanks in advance

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @acerNZ 

 

at the end you always want to replace #NV with null, right?

Then the trick is to use Table.ColumnNames in the last parameter of Table.ReplaceValue to dynamically use all column names of your table within Table.ReplaceValue

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

6 REPLIES 6
acerNZ
Helper III
Helper III

Hi @Jimmy801 Do you agree, it is too easy to just select entire excel sheet and use find and replace than this.

Jimmy801
Community Champion
Community Champion

Hello @acerNZ 

 

I cannot completely follow you. For sure, if you can change your datasource it's better. But in Power Query you need do do like this. But Power Query is mashup engine and not Excel. The same would it be how to write a VBA to do this 🙂

 

BR

 

Jimmy

acerNZ
Helper III
Helper III

Thank you @Jimmy801 , As my table has more than 20 columns, I will give it a try tomorrow. Thanks a lot

Jimmy801
Community Champion
Community Champion

Hello @acerNZ 

 

use Table.ReplaceValue and in the last paramater use the function Table.ColumnNames and refer to your prior step. Here an example

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUSpOTEkDUVAyMU0pVidayQnIUfZzRCFB4hBlELFEBCc2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}}),
    ReplaceAllNV = Table.ReplaceValue
    (
        #"Changed Type",
        "#NA", null, Replacer.ReplaceValue, Table.ColumnNames(#"Changed Type")
    )
in
    ReplaceAllNV

 

Jimmy801_0-1612936582490.png

Jimmy801_1-1612936590502.png

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

Thank you @Jimmy801  I have about 20 coloumns with different names, do I have to change the coloumn names and add the columns accordingly in my work data. Thank you so much

Jimmy801
Community Champion
Community Champion

Hello @acerNZ 

 

at the end you always want to replace #NV with null, right?

Then the trick is to use Table.ColumnNames in the last parameter of Table.ReplaceValue to dynamically use all column names of your table within Table.ReplaceValue

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors