Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
jagannalla
Partner - Specialist III
Partner - Specialist III

how to remove commas in data of variable?

Hi,

- I had stored all selections of different listboxes in one variable with seperating each selection with comma.

- if i not selecting any one listbox i'm getting the comma but i want to remove this comma if i not selected that listbox.

In button action i return for variable  like this: =GetFieldSelections(F1,',',50)&','&GetFieldSelections(Group,',',50)&','&GetFieldSelections(Group1,',',50)

Eg:

I have three fields F1,Group,Group1 and taken in different listboxes. And i'm taken one variable for storing the seleted data of those listboxes with seperating comma. If i'm not selecting Group,Group1 . I'm getting the output of variable like : G,,

Here i want to remove ,,

I'm attaching my qvw file also for your reference.

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Try this out.

   =GetFieldSelections(F1,',',50)&

if(GetSelectedCount(F1) > 0 and (GetSelectedCount(Group) > 0 or GetSelectedCount(Group1)) ,',')&

GetFieldSelections(Group,',',50)&

if(GetSelectedCount(Group1) > 0 and GetSelectedCount(Group) > 0,',')&

GetFieldSelections(Group1,',',50)

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

7 Replies
Miguel_Angel_Baeyens

Hello Jacq,

Those are result of the concatenation (the &',,'& part between GetFieldSelections). You will need to add more conditionals so if the GetFieldSelections(Group, ',', 50) length is greater than zero, then use it, othwerwise null, or something.

=GetFieldSelections(F1,',',50)&If(Len(GetFieldSelections(Group,',',50)) > 0, ','&GetFieldSelections(Group,',',50)&If(Len(GetFieldSelections(Group1,',',50)) > 0, ','&GetFieldSelections(Group1,',',50)))

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

jagannalla
Partner - Specialist III
Partner - Specialist III
Author

But if i not select Group listbox it is not storing Group1 data also..

Miguel_Angel_Baeyens

Hi,

Then you will have to add more conditionals to control all possibilities or use a different function to get different values and concatentate them, using Concat() for example, and in your macro, depending on the length of the three concats() (one per each F1, Group and Group1) create the variable in accordance.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Try this out.

   =GetFieldSelections(F1,',',50)&

if(GetSelectedCount(F1) > 0 and (GetSelectedCount(Group) > 0 or GetSelectedCount(Group1)) ,',')&

GetFieldSelections(Group,',',50)&

if(GetSelectedCount(Group1) > 0 and GetSelectedCount(Group) > 0,',')&

GetFieldSelections(Group1,',',50)

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
jagannalla
Partner - Specialist III
Partner - Specialist III
Author

kaushik,

Your code is working but i need small favour from you..

Can you plz write above code for 9 fields. like G1,G2,G3,G4,G5,G6,G7,G8,G9.

B'coz i'm not able to implement your code for 9 fields...

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Let me tell you the logic this will help you to make it done.

   Look at the expression.

   After 1st get selection of F1 i gave 3 condition in if statement. and then as we go down it decreases.

   So same you have to do for 9 fields.

   Something like this.

  

   =GetFieldSelections(G1,',',50)&

if(GetSelectedCount(G1) > 0 and (GetSelectedCount(G2) > 0 or GetSelectedCount(G3)) >0 ......... or GetSelectedCount(G9) >0 ,',')&

GetFieldSelections(G2,',',50)&

if(GetSelectedCount(G2) > 0 and GetSelectedCount(G3) > 0...........GetSelectedCount(G9) >0',')&

GetFieldSelections(G3,',',50).............................

GetFieldSelections(G9,',',50)

  Try you will for sure can do this.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
jagannalla
Partner - Specialist III
Partner - Specialist III
Author

Thanks a lot kaushik..I implemented your logic.