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
eWise
Advocate I
Advocate I

Calculated Column with multiple conditions

Hi all,

Am trying to calculate a cost column based on multiple conditions but it seems like the last step where I need to calculate the results from coulmn values throws the whole thing off.

When I remove step 

'Order'[Document.orderDetails.totalMileage]* 2.5, to test, it works. Some of the columns required in the conditions are text because I have to look at customer name and also city to determine what values to apply. I will appreciate any help. Thanks

eWise_0-1631815593484.png

 

1 ACCEPTED SOLUTION

@ryan_mayu 
I figured out where I was going wrong. I was comparing a numeric column(

'Order'[Document.orderDetails.totalMileage]) to text "12". Once I changed "12" to 12, everything worked. You mentions of numeric and text prompted me to review the query and then I was able to see my mistakes. Thank you.

 

View solution in original post

6 REPLIES 6
v-yangliu-msft
Community Support
Community Support

Hi  @eWise ,

 

Has your problem been solved? If it is solved, you can mark the correct answer.

 

Best Regards,

Liu Yang

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

ryan_mayu
Super User
Super User

@eWise 

I guess it returns two type of data, if  "*2.5", will be numerical type., otherwise will be "125" which is Text.

We can't set two different data types in one column





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I ended up formating it as below which worked but some of the columns are wrongly calculated;

FORMAT(INT('Order'[Document.orderDetails.totalMileage] * 2.5 + 65), "0")
eWise_0-1631845662362.png

Mileage 1374 and 191 should be 125 since no condition is met and mileage 2.5 should be 65. Am not sure what is causing that.

@eWise 

Since you are doing the calculation. I am not sure why you want to transfer numerical type to text?

could you pls provide the pbix file?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu 
I figured out where I was going wrong. I was comparing a numeric column(

'Order'[Document.orderDetails.totalMileage]) to text "12". Once I changed "12" to 12, everything worked. You mentions of numeric and text prompted me to review the query and then I was able to see my mistakes. Thank you.

 

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.