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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Gaddam
Frequent Visitor

how can i replace numeric value by string value

Hello,

how can it posible to replace the numeric data to string? requirement is the value "-1" in Column Min and Max to be replaced by "N/A"

Gaddam_0-1677677004089.png

Thanks in advance

2 ACCEPTED SOLUTIONS
v-tangjie-msft
Community Support
Community Support

Hi @Gaddam ,

 

You can create a custom column that is "N/A" if the value of the base column is equal to -1, otherwise it is the current value of the base column. You can then delete the base column and rename the new column.

 

vtangjiemsft_0-1677810103502.pngvtangjiemsft_1-1677810122610.png

You can click "Advanced Editor" to copy and paste the following code and check the steps in the right step bar.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WctZ1NlDSUdI1BBJGSrE6YBFDmAiQgAoZwYRMzWBCxkCeoYEBQlmgbiBIBUjEEiYA0mcKEjE1VYqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Min = _t, Max = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Min", Int64.Type}, {"Max", Int64.Type}}),
    #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "_Min", each if [Min] = -1 then "N/A" else [Min]),
    #"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "_Max", each if [Max] = -1 then "N/A" else [Max]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column1",{"Min", "Max"})
in
    #"Removed Columns"

vtangjiemsft_2-1677810266135.png

Best Regards,

Neeko Tang

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

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

You should avoid doing that because that will give rise to multiple data types in those columns.  If you really do not want to see the -1, then replace them with null in the Query Editor.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

You should avoid doing that because that will give rise to multiple data types in those columns.  If you really do not want to see the -1, then replace them with null in the Query Editor.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-tangjie-msft
Community Support
Community Support

Hi @Gaddam ,

 

You can create a custom column that is "N/A" if the value of the base column is equal to -1, otherwise it is the current value of the base column. You can then delete the base column and rename the new column.

 

vtangjiemsft_0-1677810103502.pngvtangjiemsft_1-1677810122610.png

You can click "Advanced Editor" to copy and paste the following code and check the steps in the right step bar.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WctZ1NlDSUdI1BBJGSrE6YBFDmAiQgAoZwYRMzWBCxkCeoYEBQlmgbiBIBUjEEiYA0mcKEjE1VYqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Min = _t, Max = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Min", Int64.Type}, {"Max", Int64.Type}}),
    #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "_Min", each if [Min] = -1 then "N/A" else [Min]),
    #"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "_Max", each if [Max] = -1 then "N/A" else [Max]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column1",{"Min", "Max"})
in
    #"Removed Columns"

vtangjiemsft_2-1677810266135.png

Best Regards,

Neeko Tang

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

thank you for your time and solution

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.