Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
toddbuss
Creator
Creator

formatting with Class function

I have a range representing a count of days.  The functions below categorize them into 5 year segments for the X axis of a histogram. 

this one works, but is incomplete:

subfield(class(Days_to_TRD/365,5),' <= x < ',1) & '-'

this one stops showing any values:

subfield(class(Days_to_TRD/365,5),' <= x < ',1) & '-'& subfield(class(Days_to_TRD/365,5),' <= x < ',2)-1


It's as if Qlik doesn't know how to define the buckets when more than one class statement is used.  Can anyone tell me what I'm doing wrong?

Do I need to create the classes during the data load instead?

1 Solution

Accepted Solutions
mangalsk
Creator III
Creator III

=Dual(Replace(Class(Days_to_TRD/365,5),'<= x <','to'), Num(Class(Days_to_TRD/365,5)))

View solution in original post

6 Replies
antoniotiman
Master III
Master III

Hi Todd,

try this

Floor(Days_to_TRD/365,5)&'-'&(Floor(Days_to_TRD/365,5)+4)

Regards,

Antonio

marcus_sommer

Class has a third parameter which could define how class displays the results - therefore try just this:

class(Days_to_TRD/365,5, '-')

Beside them your second approach couldn't work because it creates a pure string-value and not a numeric number. If you want to display a certain formatting (which couldn't be reached with a formatting-function) you need to use a dual-function in which the string-part could be manipulated in various ways, for example with any string-functions maybe like this:

dual(replace(class(Days_to_TRD/365,5), ' <= x < ', '-'), num(class(Days_to_TRD/365,5)))

- Marcus

balabhaskarqlik

Try this:

Replace(Class(Days_to_TRD/365,5),'<= x <', '1')& '-'& Replace(Class(Days_to_TRD/365,5),'<= x <', '2')-1


balabhaskarqlik

=dual(REPLACE(CLASS(Days_to_TRD/365,5), '<= x <','1') & '-', CLASS(Days_to_TRD/365,5))

mangalsk
Creator III
Creator III

=Dual(Replace(Class(Days_to_TRD/365,5),'<= x <','to'), Num(Class(Days_to_TRD/365,5)))

toddbuss
Creator
Creator
Author

thanks.  The Dual function is new to me.  The formula works like charm.  I'll need to learn more about Dual.  🙂