Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
qw_jakub
Partner - Contributor III
Partner - Contributor III

Count in a table with two fields related to another table

Hello,

i need to count in a table which contains two fields (secondary keys), which are both linked to another table. Each field must be counted separatly. A simple example:

SessionIDEntry_GateExit_Gate
1AA
2AB
3BB
4CD
5DC
6EC
7BE
8CE
9AB
10AD

Gate_IDGate_Name
AGate_A
BGate_B
CGate_C
DGate_D
EGate_E

I would like to get a table which shows how many times was each gate used as an Entry_Gate and how many times as an Exit Gate.

Following this discussion http://community.qlik.com/thread/75611?tstart=0 I have changed the script for the second table to

Gates:

LOAD Gate_ID as Entry_Gate,

Gate_ID as Exit_Gate,

     Gate_Name

FROM

gates.xls

(biff, embedded labels, table is [List1$]);

But now, using Gate_Name as a dimenssion, I can not figure out the right expression.

count(Distinct SessionID)

counts of course only the sessions where Entry_Gate = Exit_Gate.

aggr(count(DISTINCT SessionID), Entry_Gate)

returns the right value but only for the gates, with at least one session where Entry_Gate = Exit_Gate, the rest is not calculated.

Thanks in advance for any advice or helpful hints.

A sample file with this example is attached.

Jakub

1 Solution

Accepted Solutions
Not applicable

Hi,

In Pivot chart click on Dimension Tab "Check Supress Null Values", then you see all possible entrygate count.

Hope it helps.

Best of luck

View solution in original post

3 Replies
Not applicable

Hi,

In Pivot chart click on Dimension Tab "Check Supress Null Values", then you see all possible entrygate count.

Hope it helps.

Best of luck

qw_jakub
Partner - Contributor III
Partner - Contributor III
Author

This seems to do the job well.

Thanks a lot for Your help!

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try this script.

    

Sessions:
LOAD SessionID,
     Entry_Gate as Gate_ID,
     'Entry' as Status
FROM
sessions.xls
(biff, embedded labels, table is [List1$]);

Concatenate

LOAD SessionID,
     Exit_Gate as Gate_ID,
     'Exit' as Status    
FROM
sessions.xls
(biff, embedded labels, table is [List1$]);

Gates:
LOAD Gate_ID ,
  Gate_Name
FROM
gates.xls
(biff, embedded labels, table is [List1$]);

Then create a chart with dimension " Gate_Name " and expression as

Count({<Status = {"Entry"}>}Distinct SessionID)

Count({<Status = {"Exit"}>}Distinct SessionID)

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!