Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

histogram counts duplicates

Suppose I have two tables joined by id, where one table contains this id as unique identified and second table has multiple records with the same id.

data1:

LOAD * INLINE [

    d1_ID, param1

    A1, 1

    A2, 2

    A3, 2

    A4, 3

    A5, 2

    A6, 4

    A6, 3

    A7, 5

];

data2:

LOAD * INLINE [

    d2_ID, d1_ID, other_param

    1, A1, x

    2, A1, y

    3, A1, z

    4, A2, t

    5, A2, x

    6, A3, y

    7, A4, z

    7, A4, t

    8, A6, x

];



I would like to make a histogram of param1 values, counting each once per d1_ID. But having these two tables joined, it counts '1' three times, as A1 occurs 3 times in data2 table... Any ideas how to make it?


11 Replies
YoussefBelloum
Champion
Champion

Hi,

here you can create a flag when loading each of your tables, like this you can filter your expresion with a set analysis..

it is one way to do it

Anonymous
Not applicable
Author

Hi,

Can you give me an example of how to do it?

YoussefBelloum
Champion
Champion

data1:

LOAD d1_ID, param1, 'data1' as Flag;

LOAD * INLINE [

    d1_ID, param1

    A1, 1

    A2, 2

    A3, 2

    A4, 3

    A5, 2

    A6, 4

    A6, 3

    A7, 5

];

data2:

LOAD * INLINE [

    d2_ID, d1_ID, other_param

    1, A1, x

    2, A1, y

    3, A1, z

    4, A2, t

    5, A2, x

    6, A3, y

    7, A4, z

    7, A4, t

    8, A6, x

];



expression = Count ({<Flag={'data1'}>} d1_ID)


Let me know

Anonymous
Not applicable
Author

Thank you for your reply! However, I can't use Count in histogram - I just provide the name of field, hence I don't know how to use set analysis expression in there

YoussefBelloum
Champion
Champion

What is the expression you are using on the histogram ?

Anonymous
Not applicable
Author

There is no expression. I just use one dimension field

YoussefBelloum
Champion
Champion

So you can try on the Dimension:

=if(Flag='data1', your_dimension_field)

Anonymous
Not applicable
Author

hmm... looks good, but I just tried on this dummy data and suprisingly this problem does not occur - histogram is calculated properly.. and when tried on my real data and used other parameter as a flag, it didn't work

YoussefBelloum
Champion
Champion

you can maybe add some screen shots here, from your script for example