How to convert decimal to percentage in saql?
Ayub's answer is pretty solid. I ran into the case, however, where I needed to explicitly display the measure values as %, as opposed to shifting the decimal and stating it in the column header.
Similar to Ayub's 2nd method one would change the field format. In the edge case of running the calculation in a Lens you won't see the derived fields in the Field List. Instead you need define a new derived field.
You can do this by executing the following;
- Once you've got your SAQL working, click over to the chart section. This shouldn't mess with you SAQL and will give you the option to access the Field List.
- Click on the "Fields" right above the Filters tab on the left side.
- Scroll to the bottom and find the "Derived Measures" section.
- Click "+ Add Derived Measure"
- Paste in whatever you ended up naming the field you want formatted (I would recommend using a unique and descriptive name, since that's what it will appear as.)
- Hover over the newly added derived field and click the downward-facing arrow.
- Select your number format
- Hit Save.
There are two ways to do that:
1. AT SAQL Level: Just round the row value to two decimal points using round(sum(....), 2) and show that column label as Midperf (in %) to make it clear that this column in showing value in percentage.
2. Change the format of field as Percentage at Dataset level::