简体   繁体   中英

How to replace a number with another number in Tableau?

I have a column in my worksheet in Tableau that has a value like 102%. I need to replace it with 100%. How can I do that? I already tried the following in calculated field. IF [x]>1 THEN [x]=1 ELSE [x] END

It gives me this error: Expected type boolean, found Float. Result types from IF expressions must match. How can I fix it? Thanks

You should be able to remove the [x]= and just put 1.

IF [x]>1 THEN 1 ELSE [x] END

If that doesn't work, look into converting the field to a string and converting it back to a FLOAT with something like the below:

FLOAT(IF LEFT(STR([x]),1) = 1 THEN 1 ELSE STR([x]) END)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM