Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
doublepsa
Contributor II
Contributor II

Recursive calculation of a sum based on the values of the strings

Hi, everyone, hope you're well!

 

I have a dataset with the variables nome_emissor, flag_controle, qtd_cartoes and faturamento. I need to calculate a specific sum according to the values in nome_emissor. I'll try to describe it.

I have to sum the qtd_cartoes when flag_controle = 0 and a given value in nome_emissor, and divide it for the sum of qtd_cartoes, when flag_controle = 0. Afterwards, I have to sum the above ratio for all different values in nome_emissor.

Or, if you prefer, it could be sth like it: 

sum(

sum(<flag_controle={0},nome_emissor={'A'}> qtd_cartoes)/ sum(<flag_controle={0}> qtd_cartoes)

) for all 'A'

 

Thanks in advance.

Labels (1)
1 Reply
Anil_Babu_Samineni

Perhaps this

sum({<nome_emissor={'A*'}>} Aggr((sum(<flag_controle={0},nome_emissor={'A'}> qtd_cartoes)/ sum(<flag_controle={0}> qtd_cartoes)), Dim1, Dim2))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful