Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Stringvariable in set analysis


Hi,

i define a variable as: set vSC = 'GetFieldselections(Field)';

the field variables in Field are type string. The variable works and i can see in QV that its changing value (text object) when making selections in field.

i want to use this variable in set analysis, but the exppression: sum({<val={'$(=SC)'}>} "summa över")

doesent seem to work. i have tried different solutions.

Any suggestions?

18 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

If the dimension values has any spaces then this expression won't work.

Try like this

sum({<val=P(Field)>} "summa över")



OR


vSC = chr(39) & GetFieldselections(Field, chr(39), ',', chr(39)) & chr(39)

and use below expression

sum({<val={'$(=vSC)'}>} "summa över")


Regards,

Jagan.

Not applicable
Author

Hi Jagan,

Still doesent work, i modified to = chr(39) & GetFieldSelection(Field) & chr(39), this gives quotes round the variable but the sum function still not functioning.

/Anders

Anonymous
Not applicable
Author

Hej!

I hope I understand right, maybe this work:

sum({<Val={'$(=($(vSC)))'}, Field=>} [Summa över])

I attach an example.

Hej då!

/Giuseppe

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this

sum({<val={$(=vSC)}>} [summa över])


Regards,

Jagan.

swuehl
MVP
MVP

Anders,

'still doesn't work' is not a very helpful answer to us.

Again, why don't you come up with some sample data of the two fields in question.

Using GetFieldsSelection() might finally work, but has some limitations, e.g when selecting large amounts oft values. To get  potentially needed quoting correct is also not trivial.

Since you still have issues getting the expected results, why don't you come up with some sample values of these two fields involved?

And I still got no answer why my very first suggested expression, which seems IMHO most simple and robust, is not working for you:

=sum({<val = Field >} [summa över])

where Field is the field you used in GetFieldSelections() before. This should apply the selections in field Field to field val, where values are matching.

Anonymous
Not applicable
Author

Hi Anders,

I think (like other person) it is better if you post an example (also a qvw test file) so we can understand what you need exactly.

My example is good for you or not?

/Giuseppe

sasiparupudi1
Master III
Master III

Hi In your variable trigger,

use the following

=chr(39)& Replace(GetFieldSelections(val),', ',chr(39)&','&chr(39))&chr(39)

and the set expression should be simple

sum({<val={$(=vSC)}>} [summa över])

This should work with multi selects and values with spaces in them

sasiparupudi1
Master III
Master III

PO1.pngPlease check the file

sasiparupudi1
Master III
Master III

Hi Anders,

Have you managed to get this working?

Sasi