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: 
Not applicable

Pick field/column name from a variable and use it in calculations


Can someone please let me know is it possible to pick column name from variable and use it in set analysis?

I have created a drop down and added 4 -5 column names and when user selects any column from dropdown it calculates on the basis of that something like

=Count(Distinct  {<{(year_col) = {$(year)}>} IDS)

Thanks a lot for support

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Your application works in principle. You just need to quote the year field names in your script to get the data correctly loaded in. There was also a typo in your expression 'sales' instead 'Sales'.

View solution in original post

9 Replies
swuehl
MVP
MVP

Might be possible if you use dollar sign expansion for that, something like

=Count(Distinct  {< $(year_col) = {$(year)}>} IDS)


where year_col needs to be your variable and must expand to a valid field name.

Not applicable
Author

not working i tired

swuehl
MVP
MVP

Could you post a small sample?

Not applicable
Author

sure how can i add a file here

swuehl
MVP
MVP

Use the advanced editor, there is an 'Attach file' option. Follow the link on the upper right corner in standard editor, or it should be the default editor when you edit an existing post.

Not applicable
Author

Please click on below link to download the file

https://app.box.com/s/0jirug441a1wmhvh4dqt

Thanks

Clever_Anjos
Employee
Employee

=Count(Distinct  {<{$(year_col) = {$(=year)}>} IDS)

swuehl
MVP
MVP

Your application works in principle. You just need to quote the year field names in your script to get the data correctly loaded in. There was also a typo in your expression 'sales' instead 'Sales'.

Not applicable
Author

Many thanks fro your help I wll try it.