While Tableau has a lot of basic maths and string functions, coping with hexadecimal numbers is not something it can do natively. Let's see how we can do this with calculated fields.
To make the solution easier we break the problem into two: Interpret each hexadecimal digit, and then put the results together to convert the whole number to decimal. We create a calculated field for the rightmost hex digit (1s)
To make the solution easier we break the problem into two: Interpret each hexadecimal digit, and then put the results together to convert the whole number to decimal. We create a calculated field for the rightmost hex digit (1s)
We do the same for the next digit (16s) where we can use mid([Hex No],5,1) assuming our numbers are in the format 0x023c. Likewise for the next two digits, 16^2s and 16^3s. Then we bring everything together:ifnull(int(right([Hex No],1)),case right([Hex No],1)when 'a' then 10when 'b' then 11when 'c' then 12when 'd' then 13when 'e' then 14when 'f' then 15end)
[16^3s]*16*16*16+[16^2s]*16*16+[16s]*16+[1s]
No comments:
Post a Comment