Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

STRING in a expression.... how to transform it?

I have a string made in this way:

"14|13|5"

I would like to convert this string by using a condition....

for example:  If one of the value is > 10 then transorm it in A else in B:

I would like to have as a result:

"A|A|B"

Is it possible ?

Thanks in advance

1 Solution

Accepted Solutions
vijay_iitkgp
Partner - Specialist
Partner - Specialist

If  number of | is fixed (2) then you can use expression:

If(Subfield(Field,'|',1)>10,A,B) &'|'&If(Subfield(Field,'|',2)>10,A,B)&'|&'If(Subfield(Field,'|',3)>10,A,B)

Regards

Vijay

View solution in original post

10 Replies
vijay_iitkgp
Partner - Specialist
Partner - Specialist

Is this string have fixed number of  "|" ??

Miguel_Angel_Baeyens

Hi,

Assuming the following script:

LOAD Concat(ValueCheck, '|') AS ValueCheck2;

LOAD If(SubField(Value, '|') > 10, 'A', 'B') AS ValueCheck INLINE [

Value

15|14|3

];

The field ValueCheck2 will store as you want. SubField() will return each part separated by "|", the If() will return "A" or "B", the Concat() in the preceding load will concatenate values "A" and "B" using "|" as separator and store them into a new field called ValueCheck2.

Hope that helps.

Miguel

Not applicable
Author

This has to be done as en expression of a graph... I cannot use that in a load instruction

Not applicable
Author

Indeed this the expression made for generating the string:

=concat(distinct  round(AGGR(SUM(W_FT_VALORE_NETTO),C_PROVINCIA_FATT)), '|',fieldIndex('C_PROVINCIA_FATT', C_PROVINCIA_FATT))

vijay_iitkgp
Partner - Specialist
Partner - Specialist

If  number of | is fixed (2) then you can use expression:

If(Subfield(Field,'|',1)>10,A,B) &'|'&If(Subfield(Field,'|',2)>10,A,B)&'|&'If(Subfield(Field,'|',3)>10,A,B)

Regards

Vijay

Not applicable
Author

I am sorry but I don't know the exact number .... I am very unlucky ... I know is a very complicated problem

Not applicable
Author

What do you think, Macro is the only way to cope with this problem ?

Miguel_Angel_Baeyens

Hi,

Did you try to use the same expression, but using the conditional instead?

=concat(distinct If(round(AGGR(SUM(W_FT_VALORE_NETTO),C_PROVINCIA_FATT)) > 10, 'A', 'B'), '|',fieldIndex('C_PROVINCIA_FATT', C_PROVINCIA_FATT))

Hope that helps.

Miguel

Not applicable
Author

Yes that was my first try .... but the concat function makes all difficult:

If I add a if .... it's going to show me a string made up of a number equal to my C_PROVINCIA .... and not just the aggregation made up with the sum. I cannot get why... really. The main problem is the concat function.