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

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
cancel
Showing results for 
Search instead for 
Did you mean: 
ngreddy1982
Contributor III
Contributor III

Classify under weight category

I am trying to get a report looks some thing like this which is an example from bi manager.

          

Orders/Mth 2016Under250gC250to500gC500to750gc750gto1Kgc1Kgto125Kgc125Kgto1_5Kgc1_5kgto175Kgc175kgto2KgOver2kg
12,8211,6969465252681569481286
22,6791,3427323842281247084233
91,3939015553402041116660152
101,5421,028655343214935851129
I

I have used below query

Select

  ih.[Order GuID],

  sum(il.[Gross Weight]) as ShipWeight,

  cn.[Actual Packaging], itm.[Description],

  count(il.No_) as coutn

  FROM [TBW_BI].[dbo].[dreams$Sales Invoice Line] as il

  inner join [TBW_BI].[dbo].[dreams$Sales Invoice Header] as ih

  on il.[Document No_]=ih.No_

  inner join [TBW_BI].[dbo].[dreams$Consignment] as cn

  on ih.[Consignment ID]=cn.[id]

  left join [TBW_BI].[dbo].[dreams$Item] as itm

  on cn.[Actual Packaging]=itm.[No_]

  where ih.[Ship-to Country_Region Code]='HK'

  and ih.[Shipment Date]>='2016-10-01' and ih.[Shipment Date]<'2017-03-31'

  group by  ih.[Order GuID],itm.Description, cn.[Actual Packaging]

to get table like below

Untitled1.png

now how can I classify them or group them as per the request. Got to get how many orders which count column are under 250 grams , and how many are under 250 to 500 grams etc..??

Labels (1)
17 Replies
ngreddy1982
Contributor III
Contributor III
Author

Which dimension shall i use and what expression

sunny_talwar
MVP
MVP

Dimension

Aggr(

If(ShipWeight < 250, Dual('Under250g', 1),

If(ShipWeight < 500, Dual('C250to500g', 2),

....

, [Order GuID])

Expression

Count(DISTINCT [Order GuID])

ngreddy1982
Contributor III
Contributor III
Author

I have created new straight table took only orderguid to used dimensions and under add calculated dimension i am using this. correct?

Untitled3.png

sunny_talwar
MVP
MVP

Do you see the unclosed parenthesis for each of the if? You need to close them Giridhar

ngreddy1982
Contributor III
Contributor III
Author

How to close it ?

sunny_talwar
MVP
MVP

Would you be able to share what you have typed in your dimension here? as text and not as an image

ngreddy1982
Contributor III
Contributor III
Author

Aggr(

If(ShipWeight < 250, Dual('Under250g', 1),

If(ShipWeight < 500, Dual('250to500g', 2),

If(ShipWeight < 750, Dual('500gto750g', 3),

If(ShipWeight < 1000, Dual('750gto1kg', 4),

If(ShipWeight < 1250, Dual('1kgto1.25kg', 5),

If(ShipWeight < 1500, Dual('1.25kgto1.50kg', 6),

If(ShipWeight < 1750, Dual('1.50kgto1.75kg', 7),

If(ShipWeight < 2000, Dual('1.75kgto2kg', 8),

If(ShipWeight < 7000, Dual('over2kg', 9),

[Order GuID])

sunny_talwar
MVP
MVP

Try this:

Aggr(

If(ShipWeight < 250, Dual('Under250g', 1),

If(ShipWeight < 500, Dual('250to500g', 2),

If(ShipWeight < 750, Dual('500gto750g', 3),

If(ShipWeight < 1000, Dual('750gto1kg', 4),

If(ShipWeight < 1250, Dual('1kgto1.25kg', 5),

If(ShipWeight < 1500, Dual('1.25kgto1.50kg', 6),

If(ShipWeight < 1750, Dual('1.50kgto1.75kg', 7),

If(ShipWeight < 2000, Dual('1.75kgto2kg', 8),

If(ShipWeight < 7000, Dual('over2kg', 9)))))))))),

[Order GuID])