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

Aggr and Count

Hi Qlikview Experts,

Been going at this for hours and can't figure out the right way to do this. Please see table below:

   

IDGroupDollarsCategory 1Category 2
ID001

ABC

40AGreen
ID002ABC10AYellow
ID003ABC100BBlue
ID004DEF200ABlue
ID005GHI350BGreen
ID006GHI150AGreen
ID007JKL500BBlue

Essentially I need to get the SUM where Category 1 = 'A'. However only include Groups which have at least one line item where Category 2 = 'Blue'.

From the table above, Groups ABC, DEF, and GHI each have records where Category 1='A'. Their values are 40 and 10 (for ABC), 200 (for DEF), and 150 (for GHI), respectively. However only Groups ABC and DEF have at least one line within their respective Group with a Category 2='Blue'. As a result, the output is (40 + 10 + 200 = 250) i.e. 150 from Group='GHI' should be excluded.

I am having trouble properly executing this because I either keep on getting 400 (unsuccessfully excluding the 150 of GHI) or zero.

I have been playing around with applying an AGGR by [Group] on the COUNT of lines where Category 2 = ' Blue' and only including the Dollars in the SUM if the COUNT is more than 0 but it is not working.

Appreciate the help! Thanks!

1 Solution

Accepted Solutions
sunny_talwar

May be this:

=Sum({<[Category 1] = {'A'}, Group = P({<[Category 2] = {'Blue'}>})>}Dollars)

View solution in original post

1 Reply
sunny_talwar

May be this:

=Sum({<[Category 1] = {'A'}, Group = P({<[Category 2] = {'Blue'}>})>}Dollars)