Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
GeorgeKokkinopoulos
Contributor II
Contributor II

If statement and set analysis mismatch

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

 

Labels (1)
2 Replies
Mark_Little
Luminary
Luminary

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...

BrunPierre
Partner - Master
Partner - Master

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))