Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
kakani87
Specialist
Specialist

AGGR with SET expression

Dear All,

I want your help to find out something based on the aggr().

I'm having a data with me invoice,actual sale and sale but i want to display the actual sale using aggr() in the expression

expected value is 83000 as actual sale but it is showing as 149000

can any one help me .

PFA.

1 Solution

Accepted Solutions
pradosh_thakur
Master II
Master II

can you try this

sum( aggr(sum({<flag={'Asc'}>}actual_sales_val)/count({<flag={'Asc'}>}sales_pk),sales_pk))

Learning never stops.

View solution in original post

8 Replies
kakani87
Specialist
Specialist
Author

my expression as follows =sum(aggr(sum({<flag={'Asc'}>}actual_sales_val),sales_pk))

kakani87
Specialist
Specialist
Author

This exp is giving proper out put as expected

=sum(aggr(actual_sales_val,sales_pk))
but if i apply set expression it is not showing the same

=sum(aggr(sum({<flag={'Asc'}>}actual_sales_val),sales_pk))

pradosh_thakur
Master II
Master II

may be this


sum( {<flag={'Asc'} aggr(sum({<flag={'Asc'}>}actual_sales_val),sales_pk))


or

sum( total aggr(sum({<flag={'Asc'}>}actual_sales_val),sales_pk))


Why/where do you need aggr() though ? The output is 149000 for actual_sales_val and 83000 for sales. so i cant see what's wring there?

Learning never stops.
kakani87
Specialist
Specialist
Author

Hi Pradosh ....

lets say if actual sale is 6000 with in that sale value is considered as 3000 and 3000

let me explain this ...

for an invoice amount of 6000 is per an item where this was sold by 2 representatives 3000 and 3000

but invoice wise this is repeated for actualsale of 6000 based on employee

can you have a look at that sample once repeated invoice alias sales_pk  can identify them

kakani87
Specialist
Specialist
Author

Above expression is throwing syntax error and below one returns the same 149000 value

pradosh_thakur
Master II
Master II

can you try this

sum( aggr(sum({<flag={'Asc'}>}actual_sales_val)/count({<flag={'Asc'}>}sales_pk),sales_pk))

Learning never stops.
kakani87
Specialist
Specialist
Author

Thank you Pradosh for supporting me inspite of weekend holiday .

Happy New Year In Advance .

pradosh_thakur
Master II
Master II

No problem man .. Wish you the same .. cheers.

Learning never stops.