Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
cleonice_liebl
Contributor
Contributor

Criar rank com mais condições

Bom dia,

Quero criar um campo de rank dos 5 clientes com maiores resultados em % mas considerando somente aqueles que estão dentro dos 50% dos volumes em peças acumulados conforme ilustrado abaixo.

Se alguém puder me ajudar agradeço.

cleonice_liebl_2-1678456131775.png

 

 

 

 

 

 

Labels (3)
5 Replies
AustinSpivey
Partner - Creator
Partner - Creator

You can achieve this by using the Rank()Aggr()Above(), and RangeSum() functions, as well as the dimension limitation chart feature.

1. First we create our basic measures:

Volume:

=Sum(Volume)

Volume as % of Total:

=Sum(Volume) / Sum(Total Volume)

Results:

=Sum(Results)

That gives us a table like this:

AustinSpivey_1-1678469433023.png

 

2. Let's create the accumulation measure for Volume:

=RangeSum(
Above( If( Count([Client]) > 0
, (Sum(Volume) / Sum(Total Volume)) + Sum({1} 0)
, 0
)
, 0, RowNo()
)
)

This expression uses the RangeSum() and Above() functions to accumulate the Volume as % of Total measure we created in the previous step.

That should give us a table like this:

AustinSpivey_2-1678469467204.png

 

3. Now let's filter to only those [Client] values that are under the 50% cumulative Volume %:

=RangeSum(
Above( If( Count([Client]) > 0
, (Sum(Volume) / Sum(Total Volume)) + Sum({1} 0)
, 0
)
, 0, RowNo()
)
) < 0.5

Note the new < 0.5 condition that we added at the end of the expression.

This should give us something like this:

AustinSpivey_3-1678469712686.png

 

4. Now we can apply that filter to the [Client] field like so:

=Aggr(
Only({<
[Client]={"=RangeSum(Above(If(Count([Client])>0,(Sum(Volume)/Sum(total Volume))+Sum({1}0),0),0,RowNo()))<0.5"}
>} [Client])
, [Client]
)

This expression is using the Aggr() function because it allows us to use an aggregation function and, therefore, Set Analysis in order to limit values in a dimension field. The Only() function is our aggregation function in this case and the Set Expression we use is that same "under 50% cumulative volume %" measure we created in the previous step.

Make sure to uncheck the Include null values option!

That should give us a table like this:

AustinSpivey_4-1678470128174.png

 

5. Now we can use the Rank() function to rank those [Client] values on the sum of [Results], like so:

=Rank(Total Sum(Results), 4, 2)

That gives us a table like this:

AustinSpivey_5-1678470328126.png

 

6. Finally, we use the field limitation setting to limit the [Client]s to only the top 5. These the settings you can use:

AustinSpivey_6-1678470846778.png

Here's what our table should look like:

AustinSpivey_7-1678470882086.png

 

Austin Spivey | Principal Consultant @ Arc Analytics
ArcAnalytics.us | Add me on LinkedIn
cleonice_liebl
Contributor
Contributor
Author

Bom dia,

Muito obrigada pela ajuda. Não estou tendo êxito apenas na parte da classificação. Com a fórmula abaixo está considerando os clientes que estão fora dos 50%.

Fiquei em dúvida também o que quer dizer os números 4,2 da fórmula. Por acaso é o número das colunas para a seleção?

cleonice_liebl_0-1678712963348.png

obrigada

AustinSpivey
Partner - Creator
Partner - Creator

The Rank() function should not be taking into account the [Client]s that are below 50% accumulation. Did you uncheck the Include null values option for the the [Client] field?

And those other two arguments I used in the Rank(..., 4, 2) function are mode and format parameters. They specify how to display the rank number when being grouped and how to display duplicate ranks, respectively.

Here's the Qlik Help page that describes this function:

https://help.qlik.com/pt-BR/cloud-services/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/Relationa...

Austin Spivey | Principal Consultant @ Arc Analytics
ArcAnalytics.us | Add me on LinkedIn
cleonice_liebl
Contributor
Contributor
Author

Sim, desmarquei "Incluir valores nulos" do campo Cliente.

cleonice_liebl
Contributor
Contributor
Author

Na fórmula do ranking estamos considerando apenas o resultado. Não deveria inserir um filtro nela para considerar apenas os clientes que estão abaixo de 50%? Como o Qlik entende quais são? Não seria uma fórmula semelhante a que foi criado para filtro no campo cliente?

 

Obrigada