Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Q&A with Qlik - Qlik Cloud Migration: Questions about migrating to Qlik Cloud? Catch the latest replay!
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

Labels (1)
1 Solution

Accepted Solutions
swuehl
Champion III
Champion III

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
Champion III
Champion III

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
Champion III
Champion III

Could you post a small sample?

Not applicable
Author

sure how can i add a file here

swuehl
Champion III
Champion III

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
Support
Support

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

swuehl
Champion III
Champion III

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.