6 Replies Latest reply on Feb 4, 2016 6:37 AM by Shinichiro Murakami

# Number or Percentage format

Hi,

I have column called Type, contains values: P or N (percent or number).

If value has type = "P" then calc2 should be formatted sa percentage, in other case if value has type = "N" then calc2 should be formatted as number.

how can I do it?

• ###### 1. Re: Number or Percentage format

Hi Pawel

Personally I would like this feature inbuilt, so I can define them (possibly in the calculation itself)

There maybe something in here > Conditional Formatting of Measure Names/Measure Values

I'm also replying to pick up the thread

Cheers

Mark

• ###### 2. Re: Number or Percentage format

Maybe change the calc2 to this?

if ATTR([Type])="P" Then str(round(lookup(sum([CALC1])*100,0),2)) + '%' ELSE str(round(lookup(sum([CALC1]),0),2)) END

But keep in mind though, that the calculation then becomes a string data type.

1 of 1 people found this helpful
• ###### 3. Re: Number or Percentage format

First please always mention what version of Tableau you are using whenever posting anything on the forums (unless you are using the latest one). Thanks.

Find a 9.0 workbook attached. This let's you keep the numbers as numbers, but it only works if there aren't any negative values. Custom format formula is:

#,##0.0; ###.# \%

And the calc is:

IF [Type]='N' THEN [CALC2] ELSE -[CALC2] END

Like this:

--Shawn

2 of 2 people found this helpful
• ###### 4. Re: Number or Percentage format

Hi Pooja,

it's works. thanks!

• ###### 5. Re: Number or Percentage format

Shawn!

I love that trick. Great use of custom formatting!

I will have to remember this.

Pooja.

• ###### 6. Re: Number or Percentage format

Wao, It's very maniac

But I love these kind of things.

Thanks,

Shin