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: 
lukegilligan
Contributor III
Contributor III

Position Within Group

I am trying to capture against a subgroup within a group that resets to 1 every time the group changes.

For example:

Family CodeNameRelationship
1BobPrimary
1JanePartner
1RobDep Child
2FredPrimary
3AmyPrimary
3ParkerDep Child
3ElyseFriend
3ShaneFriend
3LinkinFriend
4BradPrimary
4ShelleyPartner
5SamPrimary
5OliviaFriend

What I need is an additional field that captures if their relationship is Primary, or Friend, and increases the counter within the family every time this happens, like in the table below:

Family CodeNameRelationshipPosition
1BobPrimary1
1JanePartner1
1RobDep Child1
2FredPrimary1
3AmyPrimary1
3ParkerDep Child1
3ElyseFriend2
3ShaneFriend3
3LinkinFriend4
4BradPrimary1
4ShelleyPartner1
5SamPrimary1
5OliviaFriend2

Any help would be much appreciated.

1 Solution

Accepted Solutions
YoussefBelloum
Champion
Champion

Hi,

Add this line into your load:

if(Relationship='Friend',AutoNumber(RowNo(),[Family Code])+1,1) as Position


PFA

View solution in original post

6 Replies
YoussefBelloum
Champion
Champion

Hi,

Add this line into your load:

if(Relationship='Friend',AutoNumber(RowNo(),[Family Code])+1,1) as Position


PFA

YoussefBelloum
Champion
Champion

And maybe stalwar1 can give you another alternative using only frond-end expression.

Tried with rangesum & above but I was stuck..

sunny_talwar

Something like this

=Aggr(If(Relationship = 'Friend', RangeSum(Above(TOTAL Column(1)), 1), 1), RowNum)


Capture.PNG


But I suggest this to be handled in script just like you did youssef

YoussefBelloum
Champion
Champion

Thanks Buddy, you rock !

here you go Luke, good luck

lukegilligan
Contributor III
Contributor III
Author

Such an elegant solution that worked perfectly, thank you so much sir, you have made my day!!

Thanks again

YoussefBelloum
Champion
Champion

You're welcome, good luck