Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Weight ranges

Hi,

I am trying to group some shipment data by weight range in a Straight table, however I can only get it to work partially.

At the moment I am using an IF function like this:

=If(SHP_WEIGHT <=0.50, '0.5KG',

If(SHP_WEIGHT >>0.50<=1.00, '1KG',

If(SHP_WEIGHT >>1.01<=2.00, '2KG',

If(SHP_WEIGHT >>2.01<=3.00, '3KG',

If(SHP_WEIGHT >>3.01<=4.00, '4KG',

'unknown')))))

This is not giving me the result I need.

The 2KG range now shows from 2.00 up to 6.00 and the 3KG range shows for 6.00 up to 16.00.

How can I fix this?

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

Definitely, we are missing Aggr here...

Something like

Aggr(

If(SHP_WEIGHT <=0.50, '0.5KG',

If(SHP_WEIGHT >0.50<=1.00, '1KG',

If(SHP_WEIGHT >1.00<=2.00, '2KG',

If(SHP_WEIGHT >2.00<=3.00, '3KG',

If(SHP_WEIGHT >3.00<=4.00, '4KG',

'unknown'))))),Shipment)

Expression

COUNT(Distinct Shipment)

View solution in original post

5 Replies
MK_QSL
MVP
MVP

=If(SHP_WEIGHT <=0.50, '0.5KG',

If(SHP_WEIGHT >0.50<=1.00, '1KG',

If(SHP_WEIGHT >1.00<=2.00, '2KG',

If(SHP_WEIGHT >2.00<=3.00, '3KG',

If(SHP_WEIGHT >3.00<=4.00, '4KG',

'unknown')))))

tresesco
MVP
MVP

Class() would be a better option.

Not applicable
Author

Hi Manisch,

I'm afraid your suggeestion is not working for me, I am not allowed to use the single ">" option, does this mean there is something wrong with the data?

MK_QSL
MVP
MVP

Definitely, we are missing Aggr here...

Something like

Aggr(

If(SHP_WEIGHT <=0.50, '0.5KG',

If(SHP_WEIGHT >0.50<=1.00, '1KG',

If(SHP_WEIGHT >1.00<=2.00, '2KG',

If(SHP_WEIGHT >2.00<=3.00, '3KG',

If(SHP_WEIGHT >3.00<=4.00, '4KG',

'unknown'))))),Shipment)

Expression

COUNT(Distinct Shipment)

deepakqlikview_123
Specialist
Specialist

use class function for this,but in this case u will get fixed range,

Thanks