2
votes

I am trying to divide values from the same pill in Tableau. Per my screenshot, the pill is named "Animals" & the grouped values within that pill are dog, cat, hamster & horse.

How can I divide dog by cat? How can I divide hamster by horse? How I divide cat by hamster? etc.

How would I create a calculation to show the desired values?

enter image description here

1
could you please provide a sample output?Fabio Fantoni
@AnilGoyal I have just added in another image to show the pill usedJ A
@AnilGoyal the expected outcome is for there to be a table of numbers that are divided by each other to create ratios & no, I do not use Tableau prepJ A
See your expected results require pivoting of rows to columns, which is possible in Prep and not in tableau desktop/public. If you want I could show you a method how to do it in data source application then ilke excel, sql? By Expected results I mean what are the results in case of NULL/NA/division by 0. All this you have to take care ofAnilGoyal
@AnilGoyal It can be done in Tableau Desktop, yes, please show me. & in case of Null, I would like it to be blank or 0J A

1 Answers

0
votes

Without the option of pivoting rows to columns available in Tableau Desktop, you have to manually create each of the desired ratio calculated field.

I have created a sample data by sampling 200 rows in a Programming language

Your created view is like this

enter image description here

Now create a calculated field for each of the desired ratio. say cat/dog like this

ZN(SUM(IF [Animals] = "cat" then 1 else 0 END))/ 
ZN(SUM(IF [Animals] = "dog" then 1 else 0 END))

Better use this field as discreet

Add this field to view you'll get desired ratios

enter image description here