14 Replies Latest reply: Feb 2, 2016 5:37 AM by Chanty 4u RSS

    RE:Size Reduce

    Chanty 4u

      hi all,

       

       

      I have small issue:

       

      I need to reduce the size of the label into two lines

       

      means length of the label values.

       

      Example: in my image i hve label name  pharmacy h/w replacement     it is in single line.

       

      REQ: i need that in   two lines:  like:  pharmacy h/w

                                                                            replacement

       

      Please refer the image .

       

      size1.png

       

      Thanks in advance.

      Suresh

        • Re: RE:Size Reduce
          Steve Dark

          Is it just this one label, or do you require a rule to split labels?

           

          If it is just the one, you can do this in the load script:

           

          LOAD

             MyField,

             Replace(MyField, 'pharmacy h/w replacement', 'pharmacy h/w' & chr(10) & 'replacement') as MyDimension,

           

          This will give you two fields, with and without the line break, so you can use different in different places - you could just rename the field if you only need it once.

           

          If it needs to be more general you could replace all spaces:

           

             Replace(MyField, ' ', chr(10)) as MyDimension,


          But it looks like that could get messy for you.


          Working out to only replace a space with a line break if it is in the middle of a long dimension could get quite tricky to achieve.


          Hope that helps.


          Steve

           

            • Re: RE:Size Reduce
              Chanty 4u

              thnx alot fr ur reply dark.

               

              I need for dimension level. not for single field.

                • Re: RE:Size Reduce
                  Steve Dark

                  In that case, you could do the thing of replacing all spaces or underscores with new line characters:

                   

                  Replace(Replace(MyField, '_', ' '), ' ', chr(10)) as MyDimension,

                   

                  This will result in many lines for some dimensions though.  Another approach is to create an ApplyMap table of original and replaced dimension names in Excel.  Here you can list all of the original names (which you can copy and paste from a LisBox) and then type into the next cell a new name, that can include line feeds.

                   

                  You would then have the syntax:

                   

                  Map_2LineDim:

                  LOAD

                     Orig,

                     New

                  FROM [.\RenameDims.xls]

                  (biff, embedded labels, header is 1 lines, table is [Rename$]);

                   

                  LOAD

                     MyField,

                     ApplyMap('Map_2LineDim', MyField) as MyDimension,

                     ...

                   

                  This way you can control exactly what you have for each dimension.  Also, given that ApplyMap defaults to the original value when no lookup match is found, any values which you don't put in the lookup will appear as they did before.

                   

                  This post gives a lot more information on ApplyMap:

                  http://www.quickintelligence.co.uk/applymap-is-it-so-wrong/

                   

                  Steve

              • Re: RE:Size Reduce
                Gysbert Wassenaar

                I recommend changing the chart orientation on the Style tab so the bars are displayed horizontally. You can resize the chart so the labels show correctly. And you can insert line breaks like Steve explained.

                • Re: RE:Size Reduce
                  Hirish V

                  Hi ,

                   

                  By Horizontal orientation  and Control shift you can make your right view,

                  Bar chart Label.PNG

                  HTH,

                  Hirish

                    • Re: RE:Size Reduce
                      Chanty 4u

                      i tried dat one bro...but  i need verical only.... that label names shud be in two lines.

                        • Re: RE:Size Reduce
                          jagan mohan rao appala

                          Hi,

                           

                          The best option for this scenario is use horizontal orientation.

                           

                          Regards,

                          Jagan.

                          • Re: RE:Size Reduce
                            Jonathan Dienst

                            It is a little complex to break intelligently on spaces or hyphens, but here some code that you could incorporate into your load after you have loaded the table containing the label to split. Assuming the table is named Data and the field is called Label:

                             

                            Set vBreak = 20;  // maximum length

                             

                            WrapLabel:

                            LOAD Label,

                              If(t1 = 0 And t2 = 0 And ln <= $(vBreak),

                              Label,

                              If(t1 = 0 And t2 = 0 And ln > $(vBreak) And ln <= $(vBreak) * 2,

                              Left(Label, $(vBreak)) & chr(10) & Mid(Label, $(vBreak) + 1, 999),

                              If(t1 = 0 And t2 = 0 And ln > $(vBreak) * 2,

                              Left(Label, $(vBreak)) & chr(10) & Mid(Label, $(vBreak) + 1, $(vBreak)*2 - 1) & chr(10) & Mid(Label, $(vBreak)*2, 999),

                              If(t1 > 0 And t2 <= t1,

                              Left(Label, t1) & chr(10) & Mid(Label, t1 + 1, 999),

                              If(t2 > t1,

                              Left(Label, t1) & chr(10) & Mid(Label, t1 + 1, t2 - t1 -1) & chr(10) & Mid(Label, t2 + 1, 999)

                              ))))) As WrapLabel

                            ;

                            LOAD *,

                              If((t1 > 0) And (ln - t1 > $(vBreak)), Index(Mid(st, t1 + 1, $(vBreak)), ' ', -1) + t1, 0) As t2

                            ;

                            LOAD *,

                              If(ln > $(vBreak), Index(Left(st, $(vBreak)), ' ', -1), 0) As t1

                            ;

                            LOAD *,

                              Len(Label) As ln,

                              Replace(Label, '-', ' ') As st

                            ;

                            LOAD Distinct

                              Label

                            Resident Data;

                             

                            This can remain as a separate table and you can use WrapLabel in place of Label as the chart dimension. Adapt the script to your table and field names. Set vBreak to a suitable break size.

                             

                            EDIT - on further testing, found a bug with the fixed wrap which is now fixed.

                             

                            t1.png

                        • Re: RE:Size Reduce
                          Settu Periyasamy

                          May be try with Calculated Dimension. Like

                           

                          =if(FindOneOf(Dim,' ',1)<10,Left(Dim,FindOneOf(Dim,' ',2))&chr(10)&Mid(Dim,FindOneOf(Dim,' ',2),Len(Dim)) ,

                          if(FindOneOf(Dim,' ',2)>=10,Left(Dim,FindOneOf(Dim,' ',1))&chr(10)&Mid(Dim,FindOneOf(Dim,' ',1),Len(Dim)),Dim))


                          Capture.JPG

                            • Re: RE:Size Reduce
                              Chanty 4u

                              hi settu ,

                               

                              small changes to ur expression .got the olution wat i required.

                               

                               

                              =left(Account, findoneof(Account, ' ', ceil(substringcount(Account, ' ')/2))) & chr(13) & chr(10) & right(Account, len(Account) - findoneof(Account, ' ', ceil(substringcount(Account, ' ')/2)))

                               

                               

                              thanks

                              Suresh

                            • Re: RE:Size Reduce
                              P M

                              Try this

                               

                              try this...

                               

                              =replace(field name,' ',chr(13)&' ')