Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
wongsimoncm
New Contributor II

Copying the values from one dimension to another dimension and clear the previous one

I have 2 dimensions, namely OriginCountry and ControllingCountry. I have created 2 buttons to look at 2 reports by different countries and also the dimension related to the report. For example, I have a button called "Generate Report by Origin Country" which shows the report by Origin Country with the OriginCountry dimension. I have another button "Generate Report by Controlling Country" and shows the ControllingCountry button.

Initially the ControllingCountry dimension will show with its chart. The customer will like to select the countries that they would like to look at, e.g. China and Malaysia. Then when they click the "Generate Report by Origin Country" button, they would like to look at the report with China and Malaysia as its origin countries and the controlling countries selected previously should be clear.

I have created a variable called v_Country to store the selected countries. What I have done is as follows:-

Under the Field Event trigger in the Settings - Document Properties,

  1. for the field OriginCountry, I have an action (OnSelect) to Set Variable "v_Country" and the formula is ='(' & concat(distinct OriginCountry, '|', fieldindex('OriginCountry', OriginCountry)) & ')'.
  2. for the field ControllingCountry, I have an action (OnSelect) to Set Variable "v_Country" and the formula is ='(' & concat(distinct ControllingCountry, '|', fieldindex('ControllingCountry', ControllingCountry)) & ')'.

Under the button "Generate Report by Origin Country", I have 2 actions:-

  1. Clear All
  2. Select in Field - Field (OriginCountry) = v_Country.

Under the button "Generate Report by Controlling Country", I have 2 actions:-

  1. Clear All
  2. Select in Field - Field (ControllingCountry) = v_Country.

Then I test my result as follow:-

  1. I select 2 countries (China and Malaysia) in ControllingCountry dimension and the controlling country report shows 2 countries (which is correct).
  2. Then I click the button "Generate Report by Origin Country" and the OriginCountry dimension shows the 2 countries and the ControllingCountry shows all countries. The v_Country shows (China,Malaysia) which is correct.
  3. If I click the "Generate Report by Controlling Country" and then "Generate Report by Origin Country" without changing my selection, the result is correct.
  4. Then I change my selection to just one country "Singapore" in ControllingCountry dimension. I can see that the value of v_Country showing (Singapore) which is correct. Then when I click the button "Generate Report by Origin Country", the OriginCountry shows the same 2 countries(China and Malaysia) I select earlier. It did not change to Singapore.
  5. When I clcik the button "Generate Report by Controlling Country", the dimension shows the 2 countries instead of SIngapore too.

Can anyone help me on this? What I have done wrong?

Tags (2)
2 Replies
Not applicable

Copying the values from one dimension to another dimension and clear the previous one

Are you verifying the value of your variable after clicking the Generate Report buttons? Creating a text box with the value =v_Country should show you what the value of the variable is. Then another with the value =GetFieldSelections(OriginCountry) will tell you which fields are actually selected.

I'm guessing that your problem is in the selection of the values when clicking the buttons. When those charts are generated and still contain the values of the two previously selected countries, that leads me to believe that the selection is not being made correctly. If your value string was off, the Trigger would probably select nothing in that field and you would get all countries. Because you are getting the previously selected countries, it is like the Trigger is not working at all. I'm going to put together a quick sample.

EDIT: This is a confusing problem. I can replicate the behavior you are describing, but I don't see why it would be doing it. Did you try removing the Clear All from the Triggers? That may do the trick, I created a sample and when I made buttons without the Clear All, it seems to be working as expected. I'll attach the sample.

llauses243
Contributor III

Re: Copying the values from one dimension to another dimension and clear the previous one

Hi NMiller,

Your post is very ilustrative, thx

This is my contribution (inc trick), pls see image adjust

Good luck, Luis