Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Aggregate over dimensions

Hi I'm trying to get the next scenario,

The info:

Country, Sales

Brasil, 10000

USA, 15000

Spain, 5000

So I want to get the percentage of each country over the country with the highest sales, in this case

Brasil,10000, 66%

USA,15000, 100%

Spain,5000, 33%



I've tried sum(Sales)/ max(aggr(sum(Sales),Country)) but I only get the same value as a regular SUM

Any Ideas?

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

Sorry for my misunderstanding

try this

sum(Sales)/ max(total aggr(sum(Sales),Country))

View solution in original post

8 Replies
Clever_Anjos
Employee
Employee

Try

sum(Sales)/ sum(TOTAL Sales)

SreeniJD
Specialist
Specialist

This formula gives the correct solution, however you might need to have another dimension like period and product which provides more accurate scenario.

.

Sum(Sales)/

Max(aggr(Sum(Sales),Country))

Lets say for Year 2015

sales would be .... sum(Sales)/Max(aggr(Sum(<Year={2015}>),Product,Country)

Sreeni

Note: You might try with TOTAL function as well..

Not applicable
Author

Thank you , but that expression gives me the % over the total amount of sales and what i want is the % over the Max amount of any country

Not applicable
Author

Ok thank you, but if I don't have any extra dimension?

For a textbox I get the right value with the expression that I posted, but I need it in a straight table as a column, If I use other more specific dimension  i don't get the right value.

I posted an excel file of what I want

Thank you

Clever_Anjos
Employee
Employee

Sorry for my misunderstanding

try this

sum(Sales)/ max(total aggr(sum(Sales),Country))

Digvijay_Singh

Sum(Sales) / Max(Total Aggr(Sum(Sales), Country))

maxgro
MVP
MVP

sum(Sales) / max(total Sales)

1.png

Not applicable
Author

Thanks everybody was very helpfull