Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register 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.

27 Replies
YoussefBelloum
Champion
Champion

You're welcome !

good luck

rkpatelqlikview
Creator III
Creator III
Author

Thanks

May i know the reason its showing the field Group that containing only Group3.

its taking for all only Group3.

Load *,

if([Vehicle Number]<100,'Group1',if([Vehicle Number]>100 and [Vehicle Number]<300,'Group2','Group3')) as Group;

SND:

LOAD

     [Carrier Name] AS [Transporter Name],

    // Datums &'|'&[Carrier Code]&'|'&[Vehicle Number] as UnitKey,

     [Vehicle Group],

     [Vehicle Number],

    VehicleTrips

FROM

[D:\Proje

table is Sheet1);

Capture123.PNG

YoussefBelloum
Champion
Champion

Can you attach your app ?

otherwise it can be caused by many things.. we should see.

be sure you don't have filters activated.

rkpatelqlikview
Creator III
Creator III
Author

Sure Youssef,

Thanks for your support. Please find the attached application. In that i should show the rating for the transporter based on the no.of vehicles and more kms travelled.

Thanks in advance.

YoussefBelloum
Champion
Champion

Hi,

here I think you should make a group by.

screen3.png

you are making comparison on the field Vehicle number which is not a number, it is a char..

what is the red part ?

rkpatelqlikview
Creator III
Creator III
Author

Hi,

No need to consider that Red.

rkpatelqlikview
Creator III
Creator III
Author

Thanks Youssef,

Then how to write this one in the script level.

if([Vehicle Number]<100,'Group1',if([Vehicle Number]>100 and [Vehicle Number]<300,'Group2','Group3')) as Group;

YoussefBelloum
Champion
Champion

The expression you mentiondd above won't work. You need an aggregation function like COUNT. And before you need to clean you field to remove the red part.

rkpatelqlikview
Creator III
Creator III
Author

Sure I will remove that.

YoussefBelloum
Champion
Champion

try to remove it on the script and make Group calculation on the expressions

remove the red part on the script with this:

SubField([Vehicle Number],'(',-1) as [Vehicle Number]