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: 
dmohanty
Partner - Specialist
Partner - Specialist

Equal Space between values of a Concatenated Field -HOW?

Hi,

I have a concatenated field like this below -

Country &  '   '  & Currency  &  '   '  &  Population as Field


But the value is coming as below, which I don't want -


United States of America USD   321.4 million

India   INR   1.311 billion


Rather, I need with some evenly space like this below -


United States of America

USD

  1. 321.4 million

India

INR

  1. 1.311 billion

How can this be achieved - either in Load Script or List Box Expression?

1 Solution

Accepted Solutions
sunny_talwar

You can try this with a monospaced font

Table:

LOAD *,

  Len(Country) as LenCountry,

  Len(Currency) as LenCurrency,

  Len(Population) as LenPopulation;

LOAD * INLINE [

    Country, Currency, Population

    United States of America, USD, 321.4 million

    India, INR, 1.311 billion

];

Left Join (Table)

LOAD Max(LenCountry) as MaxLenCountry,

  Max(LenCurrency) as MaxLenCurrency,

  Max(LenPopulation) as MaxLenPopulation

Resident Table;

FinalTable:

LOAD Country,

  Currency,

  Population,

  Country & Repeat(' ', (MaxLenCountry - LenCountry + 3)) & Currency & Repeat(' ', (MaxLenCurrency - LenCurrency + 3)) & Population as Field

Resident Table;

DROP Table Table;


Capture.PNG

View solution in original post

8 Replies
sunny_talwar

You can try this with a monospaced font

Table:

LOAD *,

  Len(Country) as LenCountry,

  Len(Currency) as LenCurrency,

  Len(Population) as LenPopulation;

LOAD * INLINE [

    Country, Currency, Population

    United States of America, USD, 321.4 million

    India, INR, 1.311 billion

];

Left Join (Table)

LOAD Max(LenCountry) as MaxLenCountry,

  Max(LenCurrency) as MaxLenCurrency,

  Max(LenPopulation) as MaxLenPopulation

Resident Table;

FinalTable:

LOAD Country,

  Currency,

  Population,

  Country & Repeat(' ', (MaxLenCountry - LenCountry + 3)) & Currency & Repeat(' ', (MaxLenCurrency - LenCurrency + 3)) & Population as Field

Resident Table;

DROP Table Table;


Capture.PNG

dmohanty
Partner - Specialist
Partner - Specialist
Author

stalwar1

Hey buddy,

This is great and appreciated.

However if I use just the Concatenated Field  as a List Box, that again gives me uneven spaces. but in the table box that is fine.

The reason I want in a List Box - need to use them as LED Check boxes, which is not possible in table Box or Straight table.

Field.png

dmohanty
Partner - Specialist
Partner - Specialist
Author

stalwar1‌,

Ohh wait!

What is that mono spaced Font?

When I just use the Format painter from Table Box to List Box - I am able to get as desired.

How can I set that?

sunny_talwar

If I use monospaced font, then it seems to be working for me

Capture.PNG

dmohanty
Partner - Specialist
Partner - Specialist
Author

Thanks stalwar1‌.

So the calculation to include the Max Length is used to Set the values in tabular format.

And then use the Monospaced font for the desired spacing.

sunny_talwar

So the calculation to include the Max Length is used to Set the values in tabular format.

Not sure I understand this... but Max length of country is used to figure out how many spaces are needed for each of the rows so that the currency can line up.... similarly max length of currency is used to figure out how many spaces are needed for each of the row so that population can line up.

And then use the Monospaced font for the desired spacing.

this is true

dmohanty
Partner - Specialist
Partner - Specialist
Author

stalwar1‌,

Your explanation to my first query is correct.

A great help and learning! Thanks again.

Regards!