Length of Comma Separated Values in Multi Value Parameter


I have a Text Field Multiline Control which takes in comma separated list of values. I am able to pass on these values to a filter to get my data from the data source. I want to calculate the number of values entered by user in this control to be used in other calculated fields. For example, if user enters Code1,Code2,Code3 then I should be able to use 3. There is no limitation on user on number of values they can enter, so, I can’t use a never ending ifelse statement.

Has anyone achieved similar functionality in QS?

Hi @NeerajGautam ,

lets assume your String parameter is called “yourString”.

You can calculate the number of elements in your list by using the following calculation:

min(strlen(${yourString})) - min(strlen(replace(${yourString}, ",",""))) + 1

You remove the commas in your string with replace(${yourString}, ",","") , then you count the letters and compare it to the original. In the end you add +1, because it is one more element than commas.

Best regards,

1 Like

Did this solution work for you? I am marking this reply as, “Solution,” but let us know if this is not resolved. Thanks for posting your questions on the QuickSight Community!

Hi Nico,

Thanks for suggesting this route. This does not work for my use case because my parameter is a multi value parameter and function strlen does not accept a String List (values returned by parameter are in the form of a list rather than a single string).

It works if I keep the parameter as a single value text field parameter and keep adding multiple codes separated by comma but I can’t use it because my backend data will not have any row with more than 1 value in code column separated by comma.

Hi @NeerajGautam ,

yes you are right.

Do you use the multiline-parameter to filter these codes in column that contains codes? If yes, you could create a distinct_count calculation on the column containing the codes. The result will be the amount of codes selected in your parameter.
Could this be a solution?

Best regards,

Hi @NeerajGautam ,

I’m marking @Nico 's above response as the solution.
Please let us know if you have further questions.

Arun Santhosh
Pr QuickSight SA