Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
Perhaps this
sum({<nome_emissor={'A*'}>} Aggr((sum(<flag_controle={0},nome_emissor={'A'}> qtd_cartoes)/ sum(<flag_controle={0}> qtd_cartoes)), Dim1, Dim2))