0
votes

I am looking to format set numbers in a Tableau column to be different based on the row title.

For example I have 1 column that contains both $ and % in the raw data. and need them to format accordingly.
I was hoping there was something I could use like"

Case
When measure = "Sales" then $
When measure = "Percent" then %
When measure = "Total" then $
End

Any suggestions would be helpful. I have been told we can't turn it into string so that won't help.

Thanks, Scott

2
could you provide an example of what the values are e.g. is the percent in a decimal as 0.5 and you are wanting to display it as 50%? What are you trying to acheive (data transformation or axis labels?)smb
Trying to achieve the label after the number. I am already doing a data transform to make it 50 the raw data comes in as 0.50. However the percent is only on a couple of rows.SASUSMC
and how are you display the data? i..e is the label for a bar graph/text tablesmb
It is in a text table- sorry would attach but working on my partner's machine and don't have the file. I tried a conversion to string and do a concatenate but ended up with some extraneous data showing up. The raw data only has 4 decimal places. However when I concatenate the number carries out to 8 decimal places and adds a 5 at the end: 50.15000005% No clue why this is happening- using Tableau 10.13SASUSMC
This might be helpful if you anyway want to have a forceful formatting.1.618

2 Answers

1
votes

Final calculation I came up with is this one:

If attr([Kpi Nm]) = "Policy Retention Better-than-State Average"
    Then str(round(sum([Actual]) * 100, 2)) + "%"
ElseIf attr([Kpi Nm]) = "Policy Retention Improvement (or > 90%)**"
    Then str(round(sum([Actual]) * 100, 2)) + "%"
Elseif attr([Kpi Nm]) = "Premium Growth"
    Then str(round(sum([Actual]) *100, 2)) + "%"
Elseif attr([Kpi Nm]) = "PIF Growth"
    Then str(round(sum([Actual]), 2))
Elseif attr([Kpi Nm]) = "Product Density"
    Then "NA"
else
   STR(ROUND(LOOKUP(sum([Actual]),0),0))
End

Thanks for the help

0
votes

Why not use the tableau calculation to have percentage & total instead of this kind of forced formatting.

I would recommend below steps:

  1. to have '$' appended to your Sales figure you simply need to change the data types of measure column (right click measure -> Default Properties -> Number Format -> select Currency (Standard) & Locale as English (United States); You should have similar flow in your version of Tableau as this is according to v10.4).
  2. drag 'row title' dimension in 'Filters' section to have only 'Sales' row selected ('Total' & 'Percentage' row from your raw data will be ignored by this).
  3. now calculate Percentage & Total using tableau calculation.

This will automatically put $ and % in your tabular view without converting the measures to dimension.

Hope this helps!