Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Set analysis issue using variable.

Hey everyone

Ive just started using QV quite recently and while i enjoy it for the most part. And thank you very much everyone who replies to all these threads its much appreciated.

Some prior info, I have searched for and read just about everything i can find about set analysis to try solve this but hasnt helped.

Right

My situation :

Im using a List Box to Display Category Groups

and another Displaying Categories

Simplistic Example here.

Group          Category   

One             Red Apple

One             Green Apple

Two             Orange

Three           Strawberry

So ive created a table similar to above. The first list box when selected will filter out results in listbox 2 simple stuff. Works great.

Now lets say i have another table which lists all transactions which has both Group and Category in each row. I dont want to link this data to these 2 seperate tables. So what i did was create a variable which would store whatever the current selection is, (if no Categories are selected for now ill just be keeping the graph blank so no stress there either). And what i want the graph to do, is to change depending on the selection. I can get this working with an IF but im trying to steer clear of them and learn Set analysis.

Variable : vVar = GetfieldSelections(Category)

Graph Dimension : Justing using category for now

Graph Expression : =count({1<Category={"$vVar"}>}Category)

MAINCategory is the transaction table category which i would like to count.

I have tried replacing the graph expression with

          =count({1<MAINCategory={'$vVar'}>}MAINCategory)

          =count({1<MAINCategory={$vVar}>}MAINCategory)

No luck.

Thanks for the effort and replies in advance guys. I can probably make up an example of what im talking about but ill only get round to it next week if needed

1 Solution

Accepted Solutions
jontydkpi
Not applicable

Set analysis issue using variable.

Brian

Is there a particular reason for not associating the tables? If not, that would be faster and simpler than what you are trying to do.

Assuming there is a reason, I don't think you need a variable to do this. Rather use the P() function in the set analysis. Something like:

     Count({<MAINCategory=P(Category)>} MAINCategory)

This will cause MAINCategory to be limited to the possible values of Category (if Category is one of the fields in the listboxes.

But you can't use Category as the dimension in the graph with set analysis. The set analysis is performed BEFORE the chart is constructed, so is unaware of the dimensions. In other words, the data passed to the chart already has the set analysis performed on it.

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
6 Replies
perumal_41
Not applicable

Set analysis issue using variable.

Hi

try this method  u get answer .i will thing

Variable : vVar = '=GetfieldSelections(Category)'

count({1<MAINCategory={'$(vVar)'}>}MAINCategory)

Regards

Perumal A

celambarasan
Not applicable

Set analysis issue using variable.

Hi,

     Can you post the table structure?

     I think its better if you link the Category and category groups internally by using same field name.

Celambarasan

jontydkpi
Not applicable

Set analysis issue using variable.

Brian

Is there a particular reason for not associating the tables? If not, that would be faster and simpler than what you are trying to do.

Assuming there is a reason, I don't think you need a variable to do this. Rather use the P() function in the set analysis. Something like:

     Count({<MAINCategory=P(Category)>} MAINCategory)

This will cause MAINCategory to be limited to the possible values of Category (if Category is one of the fields in the listboxes.

But you can't use Category as the dimension in the graph with set analysis. The set analysis is performed BEFORE the chart is constructed, so is unaware of the dimensions. In other words, the data passed to the chart already has the set analysis performed on it.

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable

Set analysis issue using variable.

Didnt work Perumal A. Thanks though i think thats something to remember for the future!

Hey Celambarasan, thanks for your reply linking them would be a good idea according to what I posted. I forgot to mention that im going to be using 2  graphs on a comparison sheet. I dont want either graphs selection/filters to affect the other. Thats why I used seperate tables to do the filtering off.

The problem is that my Set Analysis statement works if i input a text value instead of using the variable (ie use Red Apples) instead of vVar in the Set Statement.

Thanks for the quick replies!

celambarasan
Not applicable

Set analysis issue using variable.

Hi,

     Which version of qlikview are you using?

try like

Chnge your variable expression as = GetfieldSelections(Category,',')

=count({1<Category={$(vVar)}>}Category)

Celambarasan

Not applicable

Set analysis issue using variable.

Thanks Jonathan.

Using P in the set analysis seemed to do the trick!! I hope i dont get stuck with this kind of thing again though. Not sure why the variable wasnt getting accepted as is.

Sorry you were right about the dimension as well. I just made up the apples example as the data is a bit sensitive, i wasnt actually using category as the dimension