5 Replies Latest reply on Mar 17, 2016 7:50 AM by christina.butler

# Converting Numbers to Strings

Hello,

I am trying to convert a numerical value to a string but I am running into issues. The numerical value has two decimal digits but when I convert to string, the values that end in .00 are converted to integers and some of the values have about 16 digits after the decimal point. I am working with student GPA data so it is important that the format be x.xx. Below are the steps I took to convert number to string:

1. Duplicate measure value

2. Convert to dimension

3. Change data type to string

Below is a screenshot of my result and I have attached a sample workbook:

I thought this would be a relatively straightforward thing to do but just cannot figure out what is going on.

• ###### 1. Re: Converting Numbers to Strings

Hi Christina!

Yes, by default converting a number to string would cause that to happen. You can however use:

STR(round(lookup(sum([Cur Gpa]),0),2))

and place this calculation on the view. On a side note, you can run into issues with calculations on strings, is there a reason why you would use a string data type for a number that is already in 2 decimal points?

Hope this helps!

• ###### 2. Re: Converting Numbers to Strings

Actually just this would work too:

STR(round(sum([Cur Gpa]),2))

• ###### 3. Re: Converting Numbers to Strings

Thank you for your response. So the reason I need to convert the GPA to a string is because I need to replace some of the GPA values with the text "Do not release". I was thinking I could use the following if statement:

If [Release GPA] = "No"

then "Do not release"

else [Cur GPA]

END

When I use the above formula you have suggested, I get an error about mixing aggregate and non-aggregate comparisons.

• ###### 4. Re: Converting Numbers to Strings

That would be:

If ATTR([Release GPA]) = "No"

then "Do not release"

else STR(round(sum([Cur Gpa]),2))

END

• ###### 5. Re: Converting Numbers to Strings

Thank you!