7 Replies Latest reply: Nov 4, 2012 12:07 PM by Stefan Wühl

# Number format in Class() function

Hello,

I'm using the Class() function in an Calculated Dimension as this:

= Class([Ventas 2011 (Millones)], 50000, 'Ventas')

Now, this is how the Bar Chart looks like:

And I want the numbers in the dimension to have the number format, i.e. 50.000 <= Ventas < 100.000.

How can I do that?

Thanks!

Best regards!

• ###### Re: Number format in Class() function

Use Num(ClassExpression,'###.###')

Example

= Num(Class([Ventas 2011 (Millones)], 50000, 'Ventas'),'###.###')

• ###### Re: Number format in Class() function

Ok, when I use the sentence = Num(Class([Ventas 2011 (Millones)], 50000, 'Ventas'),'###.###') I have this result:

50.000, and the classes are gone...

How can I do that without sacrifying the classes???

• ###### Re: Number format in Class() function

Its not possible directly

You need to do some work around

like

=Num(SubField(Class([Ventas 2011 (Millones)], 50000, 'Ventas'),' <= Ventas < ', 1),'###.###') & ' <= Ventas < ' & Num(SubField(Class([Ventas 2011 (Millones)], 50000, 'Ventas'),' <= Ventas < ',2),'###.###')

Hope this helps

• ###### Re: Number format in Class() function

Hi.

Class() returns dual value that has numeric value and text representation.

Num() converts text representation, so this type expressions: Num(Class()) works well without any additional 'work'.

It seems that you use implicit aggregation and that's a problem when you add another function.

Choose the aggregation  explicitly:

=aggr(Num(Class([Ventas 2011 (Millones)], 50000)), [Ventas 2011 (Millones)])

• ###### Re: Number format in Class() function

Class() returns dual value that has numeric value and text representation.

Num() converts text representation, so this type expressions: Num(Class()) works well without any additional 'work'.

Right, class() returns a dual, but the numeric value will only hold the (AFAIR) lower limit of the interval that class() is creating. So, applying num() will only format that lower limit and replace the text value (which holds the full interval as text) with the formatted numeric value (like Juan observed also).

If you want to keep both limits of the interval in the text representation, I believe you need to use some kind of text manipulation, something along the lines Celambarasan suggested.

Would be nice if QV would just apply the standard number format by default.

• ###### Re: Number format in Class() function

50.000, and the classes are gone...

Thanks, Stefan, I've missunderstood.

I thought all classes rows are gone, not just '<= Ventas < N' from labels...

In that case don't see the need to use class() with string parsing functions:

=aggr(Num(Div([Ventas 2011 (Millones)],50000)*50000, '###.###') &  ' <= Ventas < ' &

Num(Div([Ventas 2011 (Millones)],50000+1)*50000, '###.###'), [Ventas 2011 (Millones)])

• ###### Re: Number format in Class() function

You're right, if you need to change the string format that class() will return, it's probably better not to use class() at all.

And if the classification is only based on field value (no aggregation, not depending on selection state), like in the discussed chart, I think it's even better to calculate the classification in the script.

You can then use one of the classification methods discussed here:

http://community.qlik.com/message/240288#240288

Regards,

Stefan