Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have created a bar chart where the dimension is TYPE (of charge) and the measure is the AMOUNT. The problem is that for a specific type (Charge 1) I need to calculate the charge as a proportion of the total charge of this type based on the proportions of another type (Charge 2) so I have used the statement below. All other charges are fine.
if(TYPE='Charge 1',
(sum({<TYPE={'Charge 2'}>} AMOUNT)/ sum({1<TYPE={'Charge 2'}>} AMOUNT))
*sum({1<TYPE={'Charge 1'}>} AMOUNT)
,
sum(AMOUNT)
)
Then in the graph I get an amount of charge for all other charges but for Charge 1 I get "-" . I guess this is because the TYPE cannot be Charge 1 (as in If statement) and Charge 2 (as in Set Analysis) at the same time.
Is there an alternative to this formula?
Thanks
Georgios
Hi,
It will be related to Type being the dimension of the chart, You could probably use chart level Scripting to do this https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/ChartLevelScripting/char...
This maybe
IF(TYPE='Charge 1',
(Sum({<TYPE={'Charge 2'}>} AMOUNT)/ Sum({<TYPE={'Charge 2'}>} TOTAL AMOUNT))* Sum({<TYPE={'Charge 1'}>} TOTAL AMOUNT),
Sum(AMOUNT))