Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
SRSB
Partner - Contributor III
Partner - Contributor III

Class function with different intervals

Hello,

I am tryin to create an interval dimension for number of months derived from a number of days field as such:

Number of months

  • <1
  • 1-2
  • 2-3
  • 3-4
  • 4-5
  • 5-6
  • 6-7
  • 7-14
  • 14-24
  • 24-36
  • >36

So far I've managed to have this result:

ssahar_1-1690490750389.png

I have a problem with the range 

  • 14-24

Below is the loading script:

If(NB_DAYS <= 30,
                '<1', 
           If(NB_DAYS < 210,
                Replace(Class (NB_DAYS/30 ,1),'<= x <','-'), 
                If(NB_DAYS >= 210 and NB_DAYS<420,Replace( Class (NB_DAYS/30 ,7) ,'<= x <','-') ,
                    If(NB_DAYS >= 420 and NB_DAYS <720,
                        Replace( Class (NB_DAYS/30 ,14) ,'<= x <','-'), 
                           If(NB_DAYS >= 360 and NB_DAYS < 1080,
                               Replace(Class(NB_DAYS/30,12),'<= x <','-'),
                         If(NB_DAYS >= 1080,  '+36')
                           )
                   )
                )
            )) as NB_MONTHS

Is there any way to get this result.

Thank you in advance.

 

Labels (2)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

try below

=if(NB_DAYS>= (30*36) , '+36'
,if(NB_DAYS>= (30*24) , '24-36'
,if(NB_DAYS>= (30*14) , '14-24'
,if(NB_DAYS>= (30*7) , '7-14'
,if(NB_DAYS<= (30) , '<1' , Replace(Class (NB_DAYS/30 ,1),'<= x <','-') )))))

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

2 Replies
vinieme12
Champion III
Champion III

try below

=if(NB_DAYS>= (30*36) , '+36'
,if(NB_DAYS>= (30*24) , '24-36'
,if(NB_DAYS>= (30*14) , '14-24'
,if(NB_DAYS>= (30*7) , '7-14'
,if(NB_DAYS<= (30) , '<1' , Replace(Class (NB_DAYS/30 ,1),'<= x <','-') )))))

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
SRSB
Partner - Contributor III
Partner - Contributor III
Author

Hello,

Thanks for your help, it worked !