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: 
mattphillip
Creator II
Creator II

Relabelling Class Function Groups

Hoping someone can help. I've used the class function to group ages to produce a bar chart. However, the labels on the X axis are not very clear as to what they refer (e.g. 20 <= 21 < rather than 20 to 29.). The calculated dimension looks like this - =Class(Age,10,Age). I've seen where some have added text boxes to cover up the labels, but is there a way of actually customising the labels?

Any help would be much appreciated.

Matt

1 Solution

Accepted Solutions
kiranmanoharrode
Creator III
Creator III

Dear Matt,    

Use replace() function for replacing '<= x <' with 'to'.

=Replace(Class(Age,10),'<= x <', 'to')

Regards,

Kiran

View solution in original post

13 Replies
kiranmanoharrode
Creator III
Creator III

Dear Matt,    

Use replace() function for replacing '<= x <' with 'to'.

=Replace(Class(Age,10),'<= x <', 'to')

Regards,

Kiran

JonnyPoole
Employee
Employee

You can wrap the result in a replace() function to get what you want . Replace '<=x <' with something better like to


replace( Class(Age,10,Age) , '<= x <' , 'to')


Capture.PNG.png

morganaaron
Specialist
Specialist

Hi Matt,

Try using the Replace function, in the format:

Replace(Class(....), '<= x <', ' to ') - this should replace the standard text a class bin width uses with your "to".

lironbaram
Partner - Master III
Partner - Master III

hi have a look at the attach example

simple replace function will do the trick

mattphillip
Creator II
Creator II
Author

Thanks Kiran (and everyone else too). Works a treat! The only thing I've noticed though is that age groupings overlap e.g. 20 to 30 (which doesn't feature anyone aged 30), 30 to 40 (which does feature those aged 30 but no one aged 40). Is there anyway to tweak this so there is no overlap e.g 20 to 29, 30 to 39?

Any help would be much appreciated.

Matt

JonnyPoole
Employee
Employee

I played around a bit more. Here is a full customization that seems to work. I'm doing a '-1' at the end of the 2nd value to reduce it by one notch. Does it help ?

=

left( Class( Sales, 1000), findoneof( Class( Sales, 1000),' ',1))

& ' to ' &

( Num(mid( Class( Sales, 1000), findoneof( Class( Sales, 1000),' ',4)))-1)

mattphillip
Creator II
Creator II
Author

Perfect Jonathan! Works a treat Many thanks everyone!

Matt

JonnyPoole
Employee
Employee

Yes ! sorry i posted the example from my own data you are correct

everything else is right.  the first space denotes the end of the first number, the 4th space denotes the start of the 2nd number...thats the key for the findoneof() function.

number <= x < 2ndnumber

mattphillip
Creator II
Creator II
Author

Ah, one slight fly in the ointment. Whilst it has sorted the groupings, it now features an empty first grouping of <blank> to <blank> with no values. I'm assuming its trying to group 0-9. Is there an easy way of hiding this empty grouping?