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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
zagzebski
Creator
Creator

Creating Calculated dimension of a range

I need to create a calculated dimension. The goal is to sum up Client Amount by Region then put into a range. The range is not in equal increments so I don't believe CLASS can be used. The data:

DATA:
RegionClientAmount
1A1000
1A2000
1B3000
1B4000
2B5000
2B6000
2B7000
2C8000
3A9000
3C10000
3C11000
SUMMED BY
  CLIENT/REGION - then the NEW FIELD IS a RANGE:
RegionClientAmountNEW FIELD
1A3000Less than 5000
1B70005000-15000
2B1800015000-30000
2C80005000-15000
3A90005000-15000
3C2100015000-30000
1 Solution

Accepted Solutions
sinanozdemir
Specialist III
Specialist III

Here is how I did it in the front-end by using Class() function:

Capture.PNG

I am also attaching the qvw.

Hope this helps.

Thanks

View solution in original post

5 Replies
petter
Partner - Champion III
Partner - Champion III

This is a simple, straightforward solution that should do what you expect:

LOAD

  Region,

  Client,

  Sum(Amount) AS Amount,

  If( Sum(Amount) < 5000 , 'Less Than 5000'

  , If ( Sum(Amount) < 15000 , '5000-15000'

  , If ( Sum(Amount) <  30000 , '15000-30000'

  , '>=30000' ))) AS [NEW FIELD]

GROUP BY

  Region, Client;

LOAD Region,

     Client,

     Amount

FROM

[https://community.qlik.com/message/850179?et=watches.email.thread#850179]

(html, utf8, embedded labels, table is @1, filters(

Remove(Row, RowCnd(Interval, Pos(Top, 1), Pos(Top, 1), Select(1, 0))),

Remove(Row, RowCnd(Interval, Pos(Top, 13), Pos(Top, 21), Select(1, 0)))

));

sinanozdemir
Specialist III
Specialist III

Here is how I did it in the front-end by using Class() function:

Capture.PNG

I am also attaching the qvw.

Hope this helps.

Thanks

petter
Partner - Champion III
Partner - Champion III

Or if you prefer do have the "raw data" in the in-memory database you could create a straight table and put in:

Region and Client as dimensions and Sum(Amount) (and name/label it Amt) as first expression and this expression:

If( Amt < 5000 , '<5000' ,

If( Amt < 15000 , '5000-15000' ,

If( Amt < 30000 , '15000-30000' ,

'>=30000' ))

as second expression.

zagzebski
Creator
Creator
Author

Took your expression made a few modifications and it worked great. Thanks!

sinanozdemir
Specialist III
Specialist III

You are welcome.

I am glad it was helpful.