Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
prat1507
Specialist
Specialist

Replace every 3rd comma with &

Hi I want to replace every third comma in my string with '&' in a text box, can someone help me please?

Regards

Pratyush

1 Solution

Accepted Solutions
sunny_talwar

May be this

=Concat(Mid(Dim,

Index(Dim, ',', 3 * (ValueLoop(1, Floor(SubStringCount(Dim, ',')/3)+1)-1)) + 1,

(If(Index(Dim, ',', 3 * (ValueLoop(1, Floor(SubStringCount(Dim, ',')/3)+1))) = 0, Len(Dim), Index(Dim, ',', 3 * (ValueLoop(1, Floor(SubStringCount(Dim, ',')/3)+1)))-1)-Index(Dim, ',', 3 * (ValueLoop(1, Floor(SubStringCount(Dim, ',')/3)+1)-1))))

, '&', ValueLoop(1, Floor(SubStringCount(Dim, ',')/3)+1))

View solution in original post

6 Replies
marcus_sommer

Maybe with something like this:

mid(Field, 1, index(Field, ',', 3) - 1) & '&' & mid(Field, index(Field, ',', 3) + 1)


- Marcus

vishsaggi
Champion III
Champion III

Can you share how your string looks like?

prat1507
Specialist
Specialist
Author

Hi Marc


This works only for the 3rd comma, I want it on 3rd, 6th, 9th and so on.....on every 3x comma.

Regards
Pratyush

prat1507
Specialist
Specialist
Author

Take any comma separated string.

Regards

Pratyush

sunny_talwar

May be this

=Concat(Mid(Dim,

Index(Dim, ',', 3 * (ValueLoop(1, Floor(SubStringCount(Dim, ',')/3)+1)-1)) + 1,

(If(Index(Dim, ',', 3 * (ValueLoop(1, Floor(SubStringCount(Dim, ',')/3)+1))) = 0, Len(Dim), Index(Dim, ',', 3 * (ValueLoop(1, Floor(SubStringCount(Dim, ',')/3)+1)))-1)-Index(Dim, ',', 3 * (ValueLoop(1, Floor(SubStringCount(Dim, ',')/3)+1)-1))))

, '&', ValueLoop(1, Floor(SubStringCount(Dim, ',')/3)+1))

prat1507
Specialist
Specialist
Author

Thanks Sunny, worked as a miracle.

Regards

Pratyush