Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
that_anonymous_guy
Contributor III
Contributor III

Is there a way to group by without using a selected column?

Hello everyone, I want to get the value like this

Item Child Item Quantity
1 01 5
1 01 5
1 02 6
1 02 6
1 03 8
1 03 8
1 04 9

I want to have the total quantity item wise i.e Item-1 should have quantity as 28. 

This is what I am doing which is giving me the total sum. 

 

Table1:

load Item, Child Item, Quantity and some other 27 columns from src; //It has around 30 columns

 

left join

Table2:

load distinct Item,sum(Quantity)

resident Table1

group by Item;

I want to join sum(quantity) field to the table but the sum should consider only distinct Child items else it would give the total sum. To get that I assume I would have to load ChildItem as well and then group by using ChildItem in addition to parent item but  If I load Child Item as well in table 2 then that will also get joined which would be wrong.

Is there a way around to get this done?

Labels (3)
1 Solution

Accepted Solutions
MayilVahanan

Hi

Try like below

Temp2:
LOAD *, Item & [Child Item] as %key INLINE [
Item, Child Item, Quantity
1, 01, 5
1, 01, 5
1, 02, 6
1, 02, 6
1, 03, 8
1, 03, 8
1, 04, 9
];

Final:

Load distinct %key, Quantity as DistinctQuantity Resident Temp2;

 

Use DistinctQuantity  in Expression. Hope It will help you.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

1 Reply
MayilVahanan

Hi

Try like below

Temp2:
LOAD *, Item & [Child Item] as %key INLINE [
Item, Child Item, Quantity
1, 01, 5
1, 01, 5
1, 02, 6
1, 02, 6
1, 03, 8
1, 03, 8
1, 04, 9
];

Final:

Load distinct %key, Quantity as DistinctQuantity Resident Temp2;

 

Use DistinctQuantity  in Expression. Hope It will help you.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.