Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Use a variable in set analysis

In the following I want to replace the expression FORT_BENENNUNG= with a variable.

=count({<FORT_BENENNUNG=>} distinct FGN_AV)

I defined the variable in an input box as:

vFORT_BENENNUNG) =   FORT_BENENNUNG=

I cannot bring the expression with the variable to work

=count({<$(vFORT_BENENNUNG)>} distinct FGN_Fahrzeug) result 0

=count({<$(=vFORT_BENENNUNG)>} distinct FGN_AV):  this ignores the set analysis

=count({<{$("vFORT_BENENNUNG)"}>} distinct FGN_AV) : no result ( -)

and other different expressions, which all did not work.

i would be happy if i could get a solutiom. Thank you in advance.

(The variable in my application is much more complex, the example posted here is simplified)

1 Solution

Accepted Solutions
marcus_sommer

Only to clarify - the variable-definition must not start with the equal-sign, only:

variable vFORT_BENENNUNG:

FORT_BENENNUNG=

and then I see that there is a space behind your variable and the bracket:

$(vFORT_BENENNUNG )

- Marcus

View solution in original post

8 Replies
jsenivifor
Contributor III
Contributor III

Hello,

To define the variable in the script:

      vFORT_BENENNUNG = " FORT_BENENNUNG =" ;


and the set of analysis :


=count({<$(vFORT_BENENNUNG )>} distinct FGN_AV)


Good Luck with QV!

marcus_sommer

This syntax: =count({<$(vFORT_BENENNUNG)>} distinct FGN_Fahrzeug) looked right. Are you sure that the result must be different to 0? How is the variable defined and how looked they within a textbox?

If you you used such expression within a table-chart and you set no label you could see within the label (per mouseover) how qlik interpreted the the expression-parts.

- Marcus

Not applicable
Author

Thank you for your answer.

Unfortunately I don't have the possibility to make changes in the script.

I have to define the variable in an Input box.

vFORT_BENENNUNG = " FORT_BENENNUNG =" in the input box doesn't work

=count({<$(vFORT_BENENNUNG )>} distinct FGN_AV): result =0

The expression:

=count({<FORT_BENENNUNG=>} distinct FGN_AV)

gives the right result (the result is independent from the filtering in field FORT_BENENNUNG)

Not applicable
Author

Thank you for your answer.

I defined the variable in an input box as:

vFORT_BENENNUNG =   FORT_BENENNUNG=

=count({<$(vFORT_BENENNUNG )>} distinct FGN_AV)

should bring the same result as

count({<FORT_BENENNUNG=>} distinct FGN_AV)

but does not.

jsenivifor
Contributor III
Contributor III

Hello,

This  is what you need?

Use a variable in set analysis.png

marcus_sommer

Only to clarify - the variable-definition must not start with the equal-sign, only:

variable vFORT_BENENNUNG:

FORT_BENENNUNG=

and then I see that there is a space behind your variable and the bracket:

$(vFORT_BENENNUNG )

- Marcus

Not applicable
Author

Thank you very much for your help. After eliminating the space in the bracket and correcting the variable as you showed me, the expression works correctly.

Not applicable
Author

Hello

My problem was solved by Marcus Sommer.

Thanks to you also for your efforts and answer.