Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
rkpatelqlikview
Creator III
Creator III

How to divide a groups based on the records

Hi,

Can anyone please help to write the backend code for this scenario?

I have table which is having the stores and sales. I need to divide three groups.

Group1 is 0-100 sales, Group2 is 100-300 sales, above 300 sales - Group3.

How many vehicles having for each group.

I need to show group1 stores and groip2 and group3 stores in the list box and pie chart.

Thanks in advance.

1 Solution

Accepted Solutions
YoussefBelloum
Champion
Champion

Please find attached,

View solution in original post

27 Replies
YoussefBelloum
Champion
Champion

Hi,

there is a lot of methods to do it, here is one example:

Sales_table:

Load

.

.

if(sales>=0 and sales<=100,'Group1',  if(number>=100 and sales <=300,'Group2',  if(sales>300,'Group3'))) as Group

FROM

rkpatelqlikview
Creator III
Creator III
Author

Thanks for your help. Can you please provide another scenario.

When am clicking on the transporter name. it should display that group name (1,2 or 3).

and there are Three list boxes Group1,Group2, Group3 It should the transporter names.

there are three Groups. The transporter is having the 0-100 fleets

that transporter will comes under the Group1, like this group2-100-300 fleets, above 300fleets- Group3

How many vehicles having for each group.

rkpatelqlikview
Creator III
Creator III
Author

This one i have given in my front end. Like this can i write in the backend.

=IF(Count(DISTINCT  [Vehicle Number])<=100, 'Group1',

IF(Count(DISTINCT [Vehicle Number])>100 and Count(DISTINCT [Vehicle Number])<=300,'Group2',

IF(Count(DISTINCT [Vehicle Number])>300, 'Group3')))

YoussefBelloum
Champion
Champion

Can you please attach sample data ?

rkpatelqlikview
Creator III
Creator III
Author

Thanks for your help

Sample Data.  

TransNameFleets
ABC20
DEF102
GHI50
JKL202
MNO350
PQR400
STU450

ABC and GHI comes under Group1, DEF, JKL comes under Group2, MNO, PQR, STU comes under Group3.

Can i generate new fields for all these groups separately.

YoussefBelloum
Champion
Champion

Please find attached

rkpatelqlikview
Creator III
Creator III
Author

Many Thanks Youssef,

I need to show count of group1 transnames etc..

Group1  - 2

Group2- 2

Group3 - 3

YoussefBelloum
Champion
Champion

Please find attached,

rkpatelqlikview
Creator III
Creator III
Author

Thank you so much Youssef.