Issue with the change of the column precision to be 2 decimal places

  • Hello,

    I need to  change the % sales vs forecast column precision to be 2 decimal places instead of whole numbers. The confusing part is that I already have a format function and 'Po' as a '%" at the end, so I am trying to understand how I can make a % with two decimal points keeping this '%' sign in the field as well.

    My formula:

    FORMAT((f.TOTHIST - f.TOTFCST) / f.TOTFCST, 'P0') AS 'Sales VS FCST'

    How I have now

    Issue2

    If someone can help me how to adjust it and make it for example in the result as 48.88% instead of 49% that would be great!

    Thank you!!

  • Format function does not change the calculation.  It takes the results of the calculation and then modify the format.  In your case all the columns in you expression are integer, so SQL Server returns an integer and then it formats it.  If you want to have the results with decimal point, you need to cast one of your columns to another data type that supports decimal point, for example:

    FORMAT((CAST f.TOTHIST AS MONEY) - f.TOTFCST) / f.TOTFCST, 'P0') AS 'Sales VS FCST'

    Adi

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply