Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
divya_anand
Creator III
Creator III

Assigning variable value to a field?

Hi,

How do I assign the value of a variable to a field?

The scenario is - I need to Clear the selections made in only Year, Month and Day fields when I move to tab X, and when I move out of tab X the selections that were made when I moved to tab X has to be restored.

For this I am using triggers,

On activation of tab X:

1. Assigning the selections (Getfieldselections()) in Year, Month & Day Field to variables vYear, vMonth and vDay respectively

2. Clearing the selections of Year, Month & Day

On leaving tab X:

1. Assigning the values in vYear, vMonth and vDay to Year, Month & Day fields respectively

This works fine if there was only 1 selection that was made in Year, Month or Day field. But if multiple selections were made, the value that is assigned to the variables are different. for eg. when (Mar, Apr, May, Jun, Jul, Aug, Sep) are chosen in the field Month, the values that is assigned to the variable is (NOT Jan, Feb, Oct, Nov, Dec). Similarly with the Day, when 7 values are chose, (7 of 31) is assigned to the variable instead of (1,2,3,4,5,6,7)

Any suggestions on how I can go about this?

Thank you.

1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi Divya,

vYear = If(GetSelectedCount(Year)=0,'',

               If(GetSelectedCount(Year) = 1, Year, '('&Concat(DISTINCT Year,'|')&')'))

vMonth = If(GetSelectedCount(Month)=0,'',

               If(GetSelectedCount(Month) = 1, Year, '('&Concat(DISTINCT Month,'|')&')'))

vDay = If(GetSelectedCount(Day)=0,'',

               If(GetSelectedCount(Day) = 1, Year, '('&Concat(DISTINCT Day,'|')&')'))

Regards!

View solution in original post

7 Replies
sunny_talwar

I think you need to use the arguments available within GetFieldSelections() function

Capture.PNG

So something like this:

GetFieldSelections(Month, ',', 10000)

This will ensure that your selections don't turn into nots or 5 of 10000.

Please note: Make sure to increase the max_values accordingly if you have more than 10000 possible selections in the field you are using it for.

Anonymous
Not applicable

Hi Divya,

vYear = If(GetSelectedCount(Year)=0,'',

               If(GetSelectedCount(Year) = 1, Year, '('&Concat(DISTINCT Year,'|')&')'))

vMonth = If(GetSelectedCount(Month)=0,'',

               If(GetSelectedCount(Month) = 1, Year, '('&Concat(DISTINCT Month,'|')&')'))

vDay = If(GetSelectedCount(Day)=0,'',

               If(GetSelectedCount(Day) = 1, Year, '('&Concat(DISTINCT Day,'|')&')'))

Regards!

katharinakostka
Partner - Contributor III
Partner - Contributor III

Hey Divya!

You could also try alternate states.

Therefor you would put the objects of the different tabs in two different states in order that they simply don't react to each other. That means the selections would not have to be cleared and restored as they only work for the objects in the same state.

Best regards Katharina

divya_anand
Creator III
Creator III
Author

This worked perfectly fine for me, just that there was a typo in the expression for vDay (It is suppose to be Day and not Year). I have another question, is it possible to use "," as delimiter? Would it still work? I tried, but doesn't work if I replace "|" with "," in the expression. The reason I'm asking you this is - I would like to see the Selections separated by comma in the "Current Selections" box unlike what I have now (Refer to the snapshot below)

Thank you very much.

sunny_talwar

Although I am glad you got what you wanted, but I am not sure if you tried what I proposed. Should have been an easier alternative, unless you like to complicated stuff

divya_anand
Creator III
Creator III
Author

Hi Sunny,

I tried this on the first hand, dint work for me. When I make more than 1 selection in Year/Month/Day, and when I open tab X and switch to a different tab, everything was getting deselected.

Anonymous
Not applicable

Hi Divya, for select you have to use '|' instead ',' on vars.

Regards!