Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Pivot table with set analysis

Hi everybody! I have some problem with such task:

we have a table with data:

Header 1Header 2Header 3Header 4
ClientIDReceiptSumReceiptIntervalDate
11101100-20001/01/2014
11120100-20001/02/2014
11500-10002/02/2014
22700-10001/05/2014
22150100-20010/01/2014

so the task is to build a pivot table like that:

Header 1Header 2Header 3Header 4
ReceiptInterval

100-20011
0-1002 (number of customers)0
12
count of receipts

I tried several ways to build that table:

1)-in data model create table

Load

Count (ClientID) as Count_of_receipts,

ClientID ,

ReceiptInterval

resident TotalReceipts Group by ReceiptInterval, ClientID;

then use this table for building pivot tavle. It works but pivot table is insensitive to selections made by user.

2)- make table of several text objects, in each object i'll calculate certain value, for eaxmple: calculate number of customers, who have 1 receipt in the amount of 100-200, than calculate number of customers,who have 2 receipts in the amount of 100-200 etc. For such calculations I I've used set analysis, but it doesn't work.

=Count({$<ReceiptInterval={'100-200'}, count({<ReceiptInterval={'100-200)>}ReceiptInterval={1})>}distinct ClientID )

Can anybody help with this expression or another way to solve my problem? Thanks in advance!

15 Replies
MK_QSL
MVP
MVP

Sorry but I am still unclear due to your format of excel file.

If you give us exact format then only can help you.

Not applicable
Author

Comm.png

Not applicable
Author

am also confused please have look at images

Not applicable
Author

Exact format is in Example.xlsx. this is how table should look like. in Example.qvw is my variant of this table, but it doesn't suit, because of insensitivity to current selection. Can you clearify what exactly is unclear?

Not applicable
Author

Ok, lets try to explain how I tried to solve the problem.

Table with data

Header 1Header 2Header 3Header 4
ClientIDReceiptSumReceiptIntervalDate
11101100-20001/01/2014
11120100-20001/02/2014
11500-10002/02/2014
22700-10001/05/2014
22150100-20010/01/2014

I transformed to another table in script reload

Load

Count (ClientID) as Count_of_receipts,

ClientID ,

ReceiptInterval

resident TotalReceipts Group by ReceiptInterval, ClientID;

Result is next:

Calc_Table:

Header 1Header 2Header 3
Count_of_receiptsClientIDReceiptInterval
1110-100
211100-200
1220-100
122100-200

Then using this Calc_Table i build the pivot table

dimensions:

-count_of_receipts

-ReceiptInterval

expression: count(ClientID). as it should look like (see images and examples)

BUT. Because of calculation table in script I can't update pivot table after selections

Not applicable
Author

So, finally I built required table, but in very unusual way. Basically it is not a table,but 2dimension array of text objects. Every object contains expression like:

=Count ({$}If(Aggr(Count({$<ReceiptInterval={'100-200'}>}card_number),card_number)=1,card_number) )

Next object has the same expression, but with another ReceiptInterval and\or Count value:

=Count ({$}If(Aggr(Count({$<ReceiptInterval={'200-300'}>}card_number),card_number)=1,card_number) )

=Count ({$}If(Aggr(Count({$<ReceiptInterval={'200-300'}>}card_number),card_number)=2card_number) )

=Count ({$}If(Aggr(Count({$<ReceiptInterval={'200-300'}>}card_number),card_number)=3card_number) )

This "table" doesn't work very fast, but it is the only way i found...