Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rzaruvne
Contributor
Contributor

Calculate cumulative data in a table

rzaruvne_0-1746808676676.png

 

 

In the column "Total", I have a calculated measure, given by the following expression:

 

Count(DISTINCT {
<
origemEventoAtencao = {'1', '2', '3'},
tipoInternacao = {'1','2','3','4','5'},
regimeInternacao = {'1', '2'},
guiaSolicitacaoInternacao = {"*"},
dataRealizacao = {
">=$(=Date(AddMonths(Max(dataCalendario), -12)))<=$(=Date(Max(dataCalendario)))"
}
>
} guiaSolicitacaoInternacao)

+

Count(DISTINCT {
<
diariasUTI = {">0"},
guiaSolicitacaoInternacao = {"*"},
dataRealizacao = {
">=$(=Date(AddMonths(Max(dataCalendario), -12)))<=$(=Date(Max(dataCalendario)))"
}
>
} guiaSolicitacaoInternacao)

 

In the column "Contribuição individual", the expression is a simple ratio, being the expression above divided by the sum of all values of "Total".  

 

My problem is to calculate the cumulative percentage. From the example, the values of "Percentual acumulado" must be presented as shown in the figure below

rzaruvne_1-1746809116632.png

I have already tried using the above, range sum and row functions, however, none of them generated the cumulative sum, and it also messed up the order of the rows.

If it helps, the rows are sorted like this:

rzaruvne_2-1746809302121.png

 

 

 

Labels (2)
1 Reply
rubenmarin

Hi, usually to cummulative value could be calculated as: RangeSum(Above([ExpressionToAccumulate],0,Rowno(TOTAL)))

Or, if the table has more than one dimension:

RangeSum(Above(TOTAL [ExpressionToAccumulate],0,Rowno(TOTAL)))