George Menoutis
George Menoutis

Reputation: 7240

Logic behind show/hide rows in charts

I am confused about the logic that exists behind the showing and hiding of rows in charts of QlikView/QLik Sense. Here is what I thought was the case:

  1. If, for some row, the value of a dimension is NULL, and for that dimension "Supress NULL" is on (QV) or "Include NULLs" is off(QS), then the row is not shown.
  2. If, for some row, all its expressions/measures are zero or NULL, and the object-level setting "Supress Zero Values" is on (QV), or "Include Zero Values" is off (QS), then the row is not shown.
  3. The rest of the rows are shown.

However, I get a confusing example of a measure which causes rows to disappear even though I have suppress zero values off/ inlude zero values on. Here is a small script of some sample customers and their consultation:

customer:
LOAD * INLINE [
custcode,descr
C1,pan1
C2,pan2
C3,pan3
];

consultation:
LOAD * INLINE [
custcode,grp,val,x
C2,eye,sth1,1
C2,age,20,1
C3,legs,sth2,1
C3,skin,sth5,1
C3,age,20,1
C3,age,30,1
];

As you can see, custcode C1 has no consultation lines. I proceed to create a straight table with custcode as dimension and sum(x) as measure. Here is what I get:

+----------+--------+
| custcode | sum(x) |
+----------+--------+
| C1       |      0 |
| C2       |      2 |
| C3       |      4 |
+----------+--------+

Everything fine until now. Sure enough I haven't supressed zero values: If I did, the C1 row would get removed. Also, let's note that no aggr is needed for whatever reason.

Now, let's add a set analysis to that measure to only sum x for grp='age':

sum({<grp={'age'}>}x)

This hides row C1 from sight:

+----------+-----------------------+
| custcode | sum({<grp={'age'}>}x) |
+----------+-----------------------+
| C2       |                     1 |
| C3       |                     2 |
+----------+-----------------------+

Question 1: Why does set analysis hide the row in this case?

Adding an additional measure with a value of 1 changes nothing. We can be sure this has nothing to do with zero values settings.

Now, let us add this measure:

aggr(min(0),[custcode])

The row got back, even though the new measure is NULL :

+----------+-----------------------+-------------------------+
| custcode | sum({<grp={'age'}>}x) | aggr(min(0),[custcode]) |
+----------+-----------------------+-------------------------+
| C1       |                     0 |                       - |
| C2       |                     1 |                       - |
| C3       |                     2 |                       - |
+----------+-----------------------+-------------------------+

Now, about aggr, here are two strong reasons why I think it should not be neccessary:

  1. If the set analysis measure was wrong and needed to include aggr in some way, this would still be no reason for the engine to hide the rows - it would just return a NULL for having an invalid formula. Also, this measure actually works correct, as we can see
  2. custcode is the field which creates the association between the two tables. But this doesn't seem to be the cause for it to unhide rows; actually, I get the same even with aggr(min(0),[]):
+----------+-----------------------+-----------------+
| custcode | sum({<grp={'age'}>}x) | aggr(min(0),[]) |
+----------+-----------------------+-----------------+
| C1       |                     0 |               - |
| C2       |                     1 |               - |
| C3       |                     2 |               - |
+----------+-----------------------+-----------------+

Question 2: Why does this strange aggr measure unhide the row?

Upvotes: 0

Views: 1697

Answers (1)

The Budac
The Budac

Reputation: 1633

Question 1: When you only have the one expression and add the set analysis it is like telling Qlik to select the set value. So picture 1 no selections enter image description here

picture 2 with the selection

enter image description here

So it's not that the answer is a null, it is that the associative engine has reduced that data out of the data set based on the selection / set rule.

The aggr() should definitely not be necessary there. The dimentionality of the chart will take care of the aggregation across the dimension. aggr() is only needed when you want to use an aggregation that is not controlled by the dimensions.

I do not understand what your aggr(min(0),[]) is trying to achieve and I don;'t get the same result as your table. The expression is just creating nulls because it is can't evaluate

If you want to see all members of the dimension you should tick "Show all values" on the dimensions tab rather than trying to change the expressions

enter image description here

Upvotes: 0

Related Questions