# New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Join us for a live Q&A! September 21, 10 AM ET - Onboarding Fast in Qlik Sense SaaS! REGISTER
cancel
Showing results for
Did you mean:
Master

## Flag for aggregated values

Hi Folks,

i got  a question, my data do look like:

Customer, Amount, ExpectedValue = Flag

Smith, 80,                       2

Smith, 10,                       2

Oliver, 90,                       1

Oliver, 30,                       1

my issue is, how can i create the flag on the base of aggregated values, for example

Amount of Adam is greater than 100  = 1

Amount of Smith is lower than 100 = 2

Amount of Oliver is greater than 100 = 1

i am using the function sum () and group by () and the Field: Flag gives for each line the value, i want to give the aggregated value for each customer.

does anybody have any idea, how to rectify this issue?

Thanks a lot

Beck

Labels (1)
• ### Flag for aggregated values

1 Solution

Accepted Solutions
Partner

Hi Beck,

My previous comment will satisfy your scenario. If incase, you want to achieve by using Sum() & Groupby() function, below code will help you.

Test:
Customer, Invoice, Amount

Smith, 1516S, 80

Smith, 1515S, 10

Oliver, 2020s, 90

Oliver, 2021S, 30
];

Temp_T2:
Customer,
Sum(Amount) as Tot_Amount
Resident Test
group by Customer;

NoConcatenate

T2:
Customer,
if(Tot_Amount>100,'1','2') as Flag
Resident Temp_T2;

Drop Table Temp_T2;

Join

Drop table Test;

Output:

**Confirm me, you're looking above result.

Thanks.

4 Replies
Partner

Hi Beck,

Hope below expression works for you,

Customer,

Amount,

if(Amount>100,'1','2') as Flag

from Table;

Thanks,

Kavi

Master
Author

Hi Ponkaviyarasu,

thanks a lot for your help and valuable time, i think i overlooked one point in this issue, my data do look like:

Customer, Invoice, Amount, ExpectedValue = Flag

Smith, 1516S, 80,                       2

Smith, 1515S, 10,                       2

Oliver, 2020s, 150,                       1

Oliver, 2021S, 30,                       1

i am using the function sum () and group by () and the Field: Flag gives for each line the value, i want to give the aggregated value for each customer like Adam = 1 and Smith 2.

I hope i could explain well enough, let me know if i overlooked something

Thanks a lot

Partner

Hi Beck,

My previous comment will satisfy your scenario. If incase, you want to achieve by using Sum() & Groupby() function, below code will help you.

Test:
Customer, Invoice, Amount

Smith, 1516S, 80

Smith, 1515S, 10

Oliver, 2020s, 90

Oliver, 2021S, 30
];

Temp_T2:
Customer,
Sum(Amount) as Tot_Amount
Resident Test
group by Customer;

NoConcatenate

T2:
Customer,
if(Tot_Amount>100,'1','2') as Flag
Resident Temp_T2;

Drop Table Temp_T2;

Join

Drop table Test;

Output:

**Confirm me, you're looking above result.

Thanks.

Master
Author

Hi Pokaviyarasu, thanks a lot for your help and your valuable time

Tags
Community Browser