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

Custom Column

Hi All,

 

I am trying to create custom column and the desired result is = from my column 'Family' if the value is 787 then custom column should calculate (5.5*16)+(5.5*40) = it should show the calculation result and if not result 0, however I am not able to get the output by this :

 

([Family] = "787") * ((5.5 * 16) + (5.5 * 40)), it returns with error, can you please help.

1 ACCEPTED SOLUTION

As I wrote and suspected, your 787 appears to be a number. Change your if statement so that you are comparing to the number 787 and not to the text string 787.

View solution in original post

6 REPLIES 6
pupadhya
Helper I
Helper I

Thank you for the reply, I did try the above formula, however value returns with 0 instead of showing the calculated result 

pupadhya_0-1685360895032.png

I want the end result of calculation which (5.5*16) + (5.5*40) = calculated value in the custom column

You do not show the family column in your example. My guess is that the data type in that column is number or whole number. You are checking in your logical statement if it is a text representation of a number. Hence the logical statement will return false. Power query is very aware of data types. Text does not equal number.

Thank you. this is my data type: 

pupadhya_0-1685372826762.png

My requirement is if family column returns with 787 then it should perform that calculation and place it in custom column and if family column has A320 then it should perform different calculation which I will improvise. Thanks

As I wrote and suspected, your 787 appears to be a number. Change your if statement so that you are comparing to the number 787 and not to the text string 787.

Many thanks it worked.

ronrsnfld
Super User
Super User

Did you see the error message:  We cannot apply operator * to types Logical and Number.

 

Did you try editing your code to avoid that?

 

if ([Family] = "787") then ((5.5 * 16) + (5.5 * 40)) else 0

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