# Find percentage of value with respect to another value in the same column

• 0 replies
• 52 views

• Member
• 3 replies

Hello Good Lookers!

So, a lot of times you want to check how much all values are with respect to another value in the same column and not with respect to the total.

For example, here -

You may want to check how must representatives do other states have with respect to California (US-CA).

This can be achieved in Looker by having a series of dependent table calculations (3 to be precise).

Step 1 - In the first step, we create a table calculation and set the value to 0 for all the rows except the row of interest. Here, we will set the value to 0 for all the rows except “US-CA”. The first table calculation would look like -

​if(\${us_statewise_representatives.code_us}="US-CA",\${sum_of_representatives},0)

And the output would look like -

Step 2 - In the second step, we would calculate running total of the table calculation created in Step 1. We can use Looker’s default Running total method and pick the appropriate source field. This is how the results would look like after step 2

Step 3 - Finally, we would need to find percentage of the original measure with respect to the table calculation we created in step 2. The table calculation here would look like -

\${sum_of_representatives}/\${rt_ca}

And the final output -

This topic has been closed for comments