0

# Discover: sort isn't working as expected

As shown above, sort is set to order by the average score measure, however the visual is still showing bars not sorted properly.

## 3replies

• Let me connect you
• Community_chris
• 1 yr ago
• Reported - view

Hi Yvonne,

thanks for the questions. I think the community will need more information to give you an answer.  Could you share more about the situation, when you run into this? Something like:

• What Pyramid Version are you using?
• What about a Screenshot? (Including the Dimensions, Measures and Dropzones)
• How would one replicate the issue?

Rgds
Christian

• Senior Director of Product
• Ian_Macdonald
• 1 yr ago
• Official response
• Reported - view

Hi Yvonne,

Yes, it is working correctly.

Your measure, Average Score, is calculated for the scope you have defined. For each company you are showing the average for each area as different colours. You are then showing the averages of each area for each company as a stacked bar, i.e. the height of the stacked bars is equal to the SUM of the each Company / Area Average.

You are then sorting Company by Ascending Average Score. So Pyramid calculates the Average Score for each Company and orders them accordingly. Which gives you the order you have above. It DOES NOT add up the average scores for each Area for Each Company and then sort using that SUM.

To prove this, create a new simple grid report and show company and average score, then sort by average score. You will find the order to be as in your chart.

You must remember, that what you sort by does not necessarily have to be on the chart.

To produce the ordering you want, you will need to create a new measure which is the sum of the averages of Area, then sort company by this measure.

Here's an example.

Margin is aggregated in my model as Average Margin. Here is Manufacturer showing the Margin for each Product Category as stacked bar, sorting by Margin.

Sorting Manufacturer by Margin in a grid shows the same order:

Now create the SUM of Product Category Margins as a Measure:

And sort Manufacturer by this Measure:

And the result:

I'm not sure what value there is in adding up the margins of Category, but it's your analysis!

Hope that helps.

Ian

• Yvonne_Teng
• 1 yr ago
• Accepted
• Reported - view

Ian Macdonald Thank you so much! Creating the sum variable solved the issue.