cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
eWise
Helper I
Helper 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.

 

View solution in original post

you are welcome





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

Proud to be a Super User!




Helpful resources

Announcements
Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Power BI Womens Summit 2021 768 x460.jpg

Interviews, learning sessions, allies, and more!

#PowerBIWomenSummit

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!