4 Replies Latest reply on Apr 20, 2017 10:32 AM by Deepak Rai

# Level metric - City, state and country level

In tableau, I have to show the sales percentage across all cities with the sales percentage of the state and country side by side.

The report should have 3 columns - City, Sales percent (City), Sales percent(State level), Sales percent (Country level). The state level sales will be same for all cities that come under same state. Same applies to states.

Sales percent = Units sold / Units delivered. This calculation should apply to city, state and country level metrics.

How to achieve this ?

• ###### 1. Re: Level metric - City, state and country level

Look at using a FIXED formula. For example for State it could be:

SUM({FIXED [State]:SUM([Sales])}) / SUM({FIXED [State]:SUM([Sales])})

Brackets might be out of place but you should get the idea. You would do this for State and Country, don't think fixed would be required for City.

• ###### 2. Re: Level metric - City, state and country level

Thanks Andrew. I tried this and it should have worked for any other case.

But as my metric calculation has its numerator and denominator from two different data sources, it says level of detail expression does not support multiple data sources.

Is there any other alternative.

• ###### 3. Re: Level metric - City, state and country level

I'm away from my computer but post a packaged workbook and someone on the forum should be able to pick it up

Sent from Samsung Mobile

• ###### 4. Re: Level metric - City, state and country level

Hi Dheeraj,