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

Grouping code

Hi All,

I have below codes filed CODE and I want to create grouping for that

1000100

1000101

1000102

1000103

1000104

1000200

1000201

1000202

1000203

1000204

expected output...

   

GorupCodeCode
10001001000100
1000101
1000102
1000103
1000104
10002001000200
1000201
1000202
1000203
1000204

Thanks

5 Replies
marcus_sommer

Try it with:

floor(Code / 100) * 100 as GroupCode

- Marcus

swuehl
MVP
MVP

Or maybe just

Floor( Code, 100) as GroupCode

surendraj
Specialist
Specialist

Try this

load *,if(GroupCode=Previous(GroupCode),' ',GroupCode) as Group;

LOAD distinct floor(code / 100) * 100 as GroupCode,* INLINE [

  

    code

    1000100

    1000101

    1000102

    1000103

    1000104

    1000200

    1000201

    1000202

    1000203

    1000204

];

1.png

Apply some sortings in sort tab.

swuehl
MVP
MVP

Surendra, this solution might visually group codes, but the data loses the relation for most records, i.e. Code 10000102 is not related to Group 10000100.

If you want to visually group the codes, it's better to use e.g. a pivot table.

edit:

Sorry, I've missed that you are keeping the field GroupCode in the model using the star symbol.

Hence the relation in your data would still be available.

surendraj
Specialist
Specialist

Try this

LOAD distinct floor(code / 100) * 100 as GroupCode,* INLINE [

    code

    1000100

    1000101

    1000102

    1000103

    1000104

    1000200

    1000201

    1000202

    1000203

    1000204

];

Take a pivot table--dimensions-->take Group code,Code

expressions-->1.png

Presentation-->2.png

Uncheak the Supress Zero-Values.

output will be:

3.png