Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
kunkumnaveen
Specialist
Specialist

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
Chanty4u
MVP
MVP

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

View solution in original post

7 Replies
sunny_talwar

May be this:

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

kunkumnaveen
Specialist
Specialist
Author

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

so should i write it in ADD CALCULATED  DIMENSION 

Chanty4u
MVP
MVP

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

sunny_talwar

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

Chanty4u
MVP
MVP

did u try my  Expression?

Chanty4u
MVP
MVP

share ur app? 

sivarajs
Specialist II
Specialist II

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