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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
sdhn
Responsive Resident
Responsive Resident

Calculated Column

Hi all,

 

I need to create calculated column in power bi as below:

Column =(col1-col2)/col2

 

Will appreciate your help. 

1 ACCEPTED SOLUTION

Hi @sdhn 

 

try this:

 

Column =
IF (
    [col2] = 0,
    BLANK (),
    IF ( [col1] - [col2] < 0, 0, ( [col1] - [col2] ) / [col2] )
)

 

If my posts helps, please consider accepting them as solutions to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

8 REPLIES 8
sdhn
Responsive Resident
Responsive Resident

Thanks, great help

VahidDM
Super User
Super User

Hi @sdhn 

 

Can you share a sample of your data in a text format?

 

BTW, try this:

Column =([col1]-[col2])/[col2]

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

sdhn
Responsive Resident
Responsive Resident

If both columns have "0" value output come as NaN

Column =([0]-[0])/[0]

 

output is "NaN"

 

in one row I have value for column 1 = 13

column 2 = 0

 

Column =([13]-[0])/[0]

Out put is  infinity 

 

sdhn
Responsive Resident
Responsive Resident

Sum values come in new  column come as "NaN" & in one row value of New Column is  "Infinity".  Rest rows are fine.   Any advise Thanks 

@sdhn 

Try this:

 

Column =IF([col2]=0,blank(),([col1]-[col2])/[col2])

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

sdhn
Responsive Resident
Responsive Resident

Great , thi ssolve the issue.  One more request.

I am getting negative figures in few rows. 

as -0.3 %.  I want to display any "-" as '0'.   Can you help on this too? thanks 

 

sdhn
Responsive Resident
Responsive Resident

I meant Just display 0 if there is any negative "-"  number 

Hi @sdhn 

 

try this:

 

Column =
IF (
    [col2] = 0,
    BLANK (),
    IF ( [col1] - [col2] < 0, 0, ( [col1] - [col2] ) / [col2] )
)

 

If my posts helps, please consider accepting them as solutions to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.