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

    Number format in Class() function

    Juan Escobar

      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:

       

      Class Bar Chart.png

      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
          Celambarasan Adhimulam

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

          Example

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

            • Re: Number format in Class() function
              Juan Escobar

              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
                  Celambarasan Adhimulam

                  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
                    whiteline _

                    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
                        Stefan Wühl

                        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
                            whiteline _

                            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)])