Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
beck_bakytbek
Master
Master

Class Function

Hi Folks,

i have a question:

i use Class-function to achieve the following result (please see attached screenshot),

my class-function does look like: DUAL(Replace(class(Differenz,30),'<= x <','-'),class(Differenz,30)), but i have got a following output:(see attached screenshot),

How can i achieve with class-function this expected output:

0 -30 Days

31 -90 Days

181 - 365 Days

more than 365 Days

thanks in advance

beck

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Requiring open and uneven bucket sizes is not a good use case for class() function.

You could create these buckets like

If(Differenz <=30, Dual('0 - 30 Days',0),

     If( Differenz <=90, Dual('31 - 90 Days',31),

          If(Differenz <= 180, Dual('91 - 180 Days',91),

               If(Differenz <= 365, Dual('181 - 365 Days', 181),Dual('more than 365 Days',366))

          )))

View solution in original post

4 Replies
Siva_Sankar
Master II
Master II

Beck,

I dont think that you can achieve using Class function, instead you use nested or embedded if() statements (if you need to use the calculated dimension), or use an INTERVALMATCH  with a custom bucket table in the script. To create buckets. you can check here on how to create buckets here https://community.qlik.com/blogs/qlikviewdesignblog/2014/07/14/buckets

something like below..

if(Differenz >=0 and Differenz <=3,Dual('0-30,0',1),

if(Differenz >=31 and Differenz <=90,Dual('31-90',2),

if(Differenz >=91 and Differenz <=180,Dual('91-180',3),

if(Differenz >20,Dual('Above 20',6))))))) as Days_Bucket

Eg:

If( ShippedDate - RequiredDate <= -5, 'Too early',

   If( ShippedDate - RequiredDate <= 0, 'Just in time',

   If( ShippedDate - RequiredDate <= 5, 'Small delay',

      'Large delay' ))) as Delay,

Siva

swuehl
MVP
MVP

Requiring open and uneven bucket sizes is not a good use case for class() function.

You could create these buckets like

If(Differenz <=30, Dual('0 - 30 Days',0),

     If( Differenz <=90, Dual('31 - 90 Days',31),

          If(Differenz <= 180, Dual('91 - 180 Days',91),

               If(Differenz <= 365, Dual('181 - 365 Days', 181),Dual('more than 365 Days',366))

          )))

beck_bakytbek
Master
Master
Author

Stefan,

thanks a lot for your feedback and help, your advice helps to resolve my issue.

Thanks a lot

Beck

beck_bakytbek
Master
Master
Author

Siva,

thanks a lot for your feedback and useful information about issue: Buckets

Thanks a lot