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
TOYER01
Helper I
Helper I

HOW TO TURN NEGATIVE VALUES IN A COLUMN TO ZERO

I have a column with some values containing Negatives and "NAH"

 

How can i turn those negative numbers and "nah to 0

 

that is, anytime the result in this column show a negative value or "nah" ti should automatically convert it to 0

 

TOYER01_1-1683993604863.png

 

9 REPLIES 9
Ahmedx
Super User
Super User

you have to do it in power query and for that you need to click

Screen Capture #1110.pngScreen Capture #1111.png

Ahmedx
Super User
Super User

pls try this

if 
Number.IsNaN([Sales]) or [Sales]<0
      then 0 else [Sales]

 

Screen Capture #1109.png 

It didnt work for me.

 

I have a table with 5 columns spooled from a source. So i added "sales" Column to the table.  

 

Sales Column is the result of the calculation of ColumnA divided by 2

 

So what I want is, how to turn "Nah" and all the negative numbers(See Screenshot below) to Zero (0)

 

TOYER01_0-1684011696161.png

 

Hi,

Assuming the Sales column was created in the Query Editor AND you want to get the desired result in the Query Editor itself, write this Custom column formula in the Query Editor

=if [Sales]="NaH" or [Sales]<0 then 0 else [Sales]

If you want to get the resutl in the Data Model, then write this calculated column formula

=if(or(Data[Sales]="Nah",Data[Sales]=0),0,Data[Sales])

Hope this helps.


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

thank you @Ashish_Mathur 

 

TOYER01_0-1684074994425.png

i got this error

Hi,

Does this calculated column formula work?

if(or(Data[Sales]="Nah",Data[Sales]="0"),0,Data[Sales])

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

@Ashish_Mathur , this is the error too

 

TOYER01_0-1684357970510.png

 

Hi,

Share the download link of the PBI file with the formula already written (the one that yields an error).


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

thanks @Ahmedx ,  I cant see Custom Column

 

I clicked new column, and enter the code above, gives error

 

TOYER01_0-1684003190354.png

 

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

April Fabric Community Update

Fabric Community Update - April 2024

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

March 2024 PBI Gallery Image

Power BI Monthly Update - March 2024

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