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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Unable to change data type in calculated column

Hi Everyone,

 

I am adding an addtional column in my table in data window and performing an if statement.

 

Statement : Column=IF(Table[Distance]=0,"-",100-(100*Table[Reversing Upon Vehicle Start Up]/Table[COUNT]))

 

I also want to add more column with different formulae like 

Cornering = IF(Table[Distance]=0,"=",MAX(100-((Table[Count]*1609.34)/Table[Distance]),0))
 

 

I am unable to get "-" when I am running the statement reason is my output would be a numeric number so I want to change my data type as Any so that I can perform the analysis.

 

Note: I don't want to change the type as String becuse I want to pefrom some mathematical calulcations also want to add other columns consisting Max,Min conditions. Is there any if I can add a custom column in query editor and can apply some If, Max, Min condition in column and change data type as "Any"

 

Please see the below table and expected column output

DistanceCountColumn
06-
08-
013-
015-
011-
170.142857
1130.076923
21141.5
16121.333333
25161.5625
25151.666667
32171.882353
480.5
3147.75
39201.95
3984.875
551
33132.538462
13200.65
20111.818182
4058
24201.2

 

DistanceCountColumn
06-
08-
013-
015-
011-
170.142857
1130.076923
21141.5
16121.333333
25161.5625
25151.666667
32171.882353
480.5
3147.75
39201.95
3984.875
551
33132.538462
13200.65
20111.818182
4058
24201.2

 

Kindly help

 

Regards

Uphar Tandon

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Why would string prevent you from doing your mathematical calculations?  Store as string, and then when you do want to do your calculation (and you are confident the stored string is actually a number and not just a "-") you convert the value programmatically to number.

 

Or, you know, you could use BLANK() instead of "-", and not have these issues at all.

View solution in original post

3 REPLIES 3
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Apart from what Ibendin has mentioned, the formula for MAX is wlso incorrect. 

MAX takes in Column as an input while you have given mathematical expression in the function.

 

Cornering =

var a = 'Table'[Count]*1609.34
var b = DIVIDE(a, 'Table'[Distance])
var c = 100 - b

RETURN
 
IF('Table'[Distance]=0,"=", CONVERT(c,STRING))
 
 
You can either convert the column into a string and then convert it back into integer when you want to do the MIN,MAX calculation.
 
Regards,
Harsh Nathani
 
 
 
lbendlin
Super User
Super User

Why would string prevent you from doing your mathematical calculations?  Store as string, and then when you do want to do your calculation (and you are confident the stored string is actually a number and not just a "-") you convert the value programmatically to number.

 

Or, you know, you could use BLANK() instead of "-", and not have these issues at all.

Anonymous
Not applicable

Thanks for the suggestion. Its working 🙂

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.