Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

kunkumnaveen
Contributor III

how to set a label in two rows

I have a dimension  MATERIAL  ,i need values of that filed in two rows on axis what i mean is

suppose      Ammonium chloride is it possible to change it in to   Ammonium

                                                                                                       chloride(breaking all the labels in to two rows )

 

please find the attachment

thanks

naveen

1 Solution

Accepted Solutions
sureshqv
Esteemed Contributor III

Re: how to set a label in two rows

u can give a try.

because same i got the issue before.  i used below code .its wrks fine

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

lebel.PNG

7 Replies

Re: how to set a label in two rows

May be this:

SubField(MATERIAL, ' ', 1) & Chr(10) & SubField(MATERIAL, ' ', 2)

kunkumnaveen
Contributor III

Re: how to set a label in two rows

where should i need to write this because MATERIAL is my dimension

so should i write it in ADD CALCULATED  DIMENSION 

sureshqv
Esteemed Contributor III

Re: how to set a label in two rows

u can give a try.

because same i got the issue before.  i used below code .its wrks fine

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

lebel.PNG

Re: how to set a label in two rows

Yes, instead of using MATERIAL, use the above expression.It is not going to be nice when there are more then 2 words

sureshqv
Esteemed Contributor III

Re: how to set a label in two rows

did u try my  Expression?

sureshqv
Esteemed Contributor III

Re: how to set a label in two rows

share ur app? 

sivarajs
Valued Contributor II

Re: how to set a label in two rows

i have found this query in the community, don't remember the link. Add your table and field name.

SUB SplitString (vField, vTable, vSegLen, vSplitField)

Split_temp:

LOAD *,

  trim(mid($(vField), Start, Count-1)) as Split,

  RowNo() as SplitId

;

LOAD *,

  index( mid($(vField) & ' ', Start+$(vSegLen)), ' ' )+$(vSegLen)  as Count

;

LOAD

  $(vField),

  if($(vField) = Previous($(vField))

  ,peek('Start')+peek('Count')

  ,1

  )as Start

RESIDENT $(vTable)

WHILE IterNo() <= div(len($(vField)),$(vSegLen))+1

;

LEFT JOIN($(vTable))

LOAD

  $(vField),

  concat(Split, chr(10), SplitId) as $(vSplitField)

RESIDENT Split_temp

WHERE len(trim(Split)) > 0

GROUP BY Title

;

DROP TABLE Split_temp;

END SUB

MyTable:

LOAD *, RecNo() as RecId INLINE [

Title

This is a long title that spans a long ways

This is a long title that spans a long ways

This one is even very much longer then the previous long title

A shorter title

The rain in Spain

Healthcare / Services / Consulting / Accounting

]

;

// Call parms are Field, Tablename, SplitLength, OutputSplitField

// Split the string in "Field" at the first blank after segment length of "SplitLength".

// New field "OutputSplitField" will be joined to table "Tablename"

CALL SplitString('Title', 'MyTable', 15, 'SplitTitle');

Regards,

Sivaraj

Community Browser