Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
adlim91
Contributor
Contributor

AND-mode in Set Analysis / Multiple criteria must be fulfilled

Hi all, 

I have this the following sample dataset. My design is to have several filter panes, with them I can get Sales per Industry. 

A brief explanation on the data: each industry has four scenarios, and each scenario has a matrix score. Each industry has a sales value. 

ScenarioIndustryMatrixTotal Sales per Industry
1Banks150
2Banks150
3Banks150
4Banks150
1Industrials1130
2Industrials1130
3Industrials0130
4Industrials0130
1Services1200
2Services1200
3Services0200
4Services0200
1Engineering1200
2Engineering1200
3Engineering1200
4Engineering1200

 

In my assignment, I will create filter panes, one for Scenario, one for Matrix.  I am supposed to play around the filters to do some data recovery. In the ideal case, I can filter however I want, say to get the industry's sales with Scenario 1 and 2 having a Matrix of 1, or Scenario 1, 2 and 3 with a Matrix of 0.

As an example, when I select all Scenario 1, 2, 3 and 4 and Matrix of 1, only Banks and Engineering should be filtered in.

For starting, I would have this in a table. How can I achieve this?

Thanks lots!

Labels (2)
9 Replies
JordyWegman
Partner - Master
Partner - Master

Hi Adlim,

Do you want the result in a table with only the industries with all matrix's that are 1? Or do you want a count of the industries?

The best thing would be to create this in the script with an indicator.

 

mapIndustryMatrix2Industry:
Mapping Load
  Industry,
  IF(_cntIndustry = _cntMatrix,1,0) as _indIndustryMatrix
;
Load
  Industry,
  Count(Industry) as _cntIndustry,
  Count(Matrix) as _cntMatrix
From [YourSource](qvd)
Group by Industry
;

Table:
Load
  Scenario,
  Industry,
  Matrix,
  Total Sales per Industry,
  ApplyMap('mapIndustryMatrix2Industry'),Industry,0) as _indIndustryMatrix
From [YourSource](qvd);

 

 

Now you can use the _indIndustryMatrix as a filter in your tables to only show the industries you want or use this in a formula to count the amount of industries:

 

Count(Distinct {$< _indIndustryMatrix = {1}>} Industry)

 

Jordy

Climber

Work smarter, not harder
tresesco
MVP
MVP

You can try like:

Sum({<Industry={"=Count({<Matrix={1}>}Industry)=4"}>} [Total Sales per Industry])

Capture.PNG 

lironbaram
Partner - Master III
Partner - Master III

hi 

this expression will do the trick 

sum({<Industry={"=only(Matrix)=1"}>}[Total Sales per Industry])

it will only use industries where the only value in the field Matrix is 1 

the advantage of using this method is if you add or remove  scenarios it will still work 

unlike counting 4 scenarios 

adlim91
Contributor
Contributor
Author

In my assignment, I will create filter panes, one for Scenario, one for Matrix.  I am suppose to play around the filters to do some data recovery.

In the ideal case, I can filter however I want, say to get the industry's sales with Scenario 1 and 2 having a Matrix of 1, or Scenario 1, 2 and 3 with a Matrix of 0.

lironbaram
Partner - Master III
Partner - Master III

you describe one thing at first 

now you describe something else 

so it's not really clear what you are after

adlim91
Contributor
Contributor
Author

My apologies for not being clear enough at the beginning. I have a more complicated dataset and I was trying to simplify it in my question, somehow I lost sight of clarity.

But essentially the goal is the same - to be able to filter for results based on Scenario and Matrix, but only for industries fulfilling both criteria on the selected Scenario and Matrix. I see some very much appreciated guidance provided, but in my case it needs to be a little more dynamic - that I can make selections in filter panes and get the results.

Thanks again!
adlim91
Contributor
Contributor
Author

I still have trouble figuring this out, anyone more experienced can help?

Or is it not possible to achieve in QlikSense?

Thanks!

tresesco
MVP
MVP

Could you explain the expected output against your few possible selections?
adlim91
Contributor
Contributor
Author

Sorry that I had not been very clear, below are a few examples of my desired outcome:

When Scenario = 1,2,3,4 ; Matrix = 1:

ScenarioIndustryMatrixTotal Sales per Industry
1Banks150
2Banks150
3Banks150
4Banks150
1Engineering1200
2Engineering1200
3Engineering1200
4Engineering1200

 

When Scenario = 1,2 ; Matrix = 1:

ScenarioIndustryMatrixTotal Sales per Industry
1Banks150
2Banks150
1Industrials1130
2Industrials1130
1Services1200
2Services1200
1Engineering1200
2Engineering1200

 

When Scenario = 2,3 ; Matrix = 1:

ScenarioIndustryMatrixTotal Sales per Industry
    

 

Essentially, all the Scenario selections of the Industry would have to fulfil the Matrix selection, then only the particular specific data would show up. My problem now is, it is only working the results in OR logic, which I don't want to see e.g. 

When Scenario = 2,3 ; Matrix = 1:

ScenarioIndustryMatrixTotal Sales per Industry
2Banks150
3Banks150
2Industrials1130
2Services1200
2Engineering1200
3Engineering1200

 

Anyone has any idea how I can formulate my expression? Thanks!