Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
abhaysingh
Specialist II
Specialist II

if Condition in set analysis

HI Guys,

HOw can I put below expression in Set Analysis?

=if([Category Name]='Beer',sum(Quantity)/24,sum(Quantity)/12)

thanks

Abhay

6 Replies
gautik92
Specialist III
Specialist III

Sum({<[Category Name]='Beer'>}Quantity)/24,Sum({<[Category Name]='Beer'>}Quantity)/12

sunny_talwar

I don't think this can be converted into a set analysis expression. Best you can do is this:

=Sum(Quantity)/If([Category Name] = 'Beer', 24, 12)

sunny_talwar

Alternatively you can create a flag in a script:

Table

LOAD [Category Name],

          Quantity,

          OtherField

FROM Source

FlagTable:

LOAD Distinct [Category Name],

          If([Category Name] = 'Beer', 24, 12) as Flag

Resident Table;

Expression:

Sum(Quantity)/Flag

CELAMBARASAN
Partner - Champion
Partner - Champion

Try the Below one

RangeSum(sum({<[Category Name]='Beer'>}Quantity)/24,sum({<[Category Name]-='Beer'>}Quantity)/12)


Hope this helps

sunny_talwar

Beautiful... This is very creative

mohammadkhatimi
Partner - Specialist
Partner - Specialist

Hie...


=sum({<[Category Name]={'Beer'}>}Quantity)/24+sum([Category Name]={'*'}-{'Beer'}Quantity)/12)




Hope this will helps you..!!

Regards,

Mohammad