Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

kristof_j
Contributor II

Use the value of a field to select a field in set analysis

Hi

I created a data island and the only field (A) contains other fields as values (field1 & field2). Field1 and field2 are in the model.

I use field A as a dimension in a chart.

Now I want to use the values of dimension A in my set analysis.

Something like this: count( {< (value of field A) = {1}>} distinct CustomerID) .

And it gets more complicated.

Field1 & field2 aren't actually fields in my model. But these field are in my model:

  • Customer_field1
  • Customer_field2
  • Group_field1
  • Group_field2

With avariable I can resolve this and I tried something like this:

count( {< $(vCustomer_or_GroupID)&'_'&field A = {1}>} distinct $(vCustomer_or_GroupID)

(remember, I used field A as a dimension.)

I want to create something that an enduser can switch easily between CustomerID or GroupID.

Where a GroupID contains several CustomerID's.

This doesn't  work. Due to the complexity of the dashboard I can't make large changes in the script. And the dashboard generates data for other dashboard as well. The impact would be too large.

Any suggestions?

5 Replies
saumyashah90
Valued Contributor

Re: Use the value of a field to select a field in set analysis

Usse this

=

GetFieldSelections(A)

kristof_j
Contributor II

Re: Use the value of a field to select a field in set analysis

That doens't work. I made the data Island not to select on it but to split my chart.

This is the set analyses

The Channel (or field A in my first post) has 'Car', 'Bus', 'Taxi'...

And the fields in the model are like this:

  • CustomerCarComm_BK
  • CustomerCarComm_VK
  • CustomerCar_BK
  • CustomerCar_VK
  • the same for group ...

count( {<$(vCustomer_or_Group)&CHANNEL&$(vCOMM_or_NOT)&'_'&$(vBK_or_VK) = {1}>} DISTINCT $(vCustomer_or_Group)_ID)

stigchel
Honored Contributor

Re: Use the value of a field to select a field in set analysis

Set analysis is evaluated once for the whole chart, so not for every value in the Dimension. Should you want different calculations per value in the dimension use (nested) if statements. An alternative is to pick an expression from a Concatenated string of all possible expressions per dimension value. See e.g.

http://community.qlik.com/message/435847#435847

kristof_j
Contributor II

Re: Use the value of a field to select a field in set analysis

The problem is that without variables or without an data Island I have already 24 possible expressions.

And with each channel added, 4 new expressions need to be added.

With the variables I can reduce this to 6 expressions but if I could make it work as in my post, than I would have only 1 expressions.

stigchel
Honored Contributor

Re: Use the value of a field to select a field in set analysis

Yes well, both $ variables and Set analysis are evaluated once for the whole chart, there is no going around that. So IF you need a different expression per dimension value and you have that many, then load an expression string for each dimension value in your loadscript, you can then pick match the correct expression, see the link I sent in my previous post

Community Browser