Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

katarzyna_wojci
New Contributor II

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?


Tags (1)
11 Replies
YoussefBelloum
Esteemed Contributor

Re: histogram counts duplicates

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

katarzyna_wojci
New Contributor II

Re: histogram counts duplicates

Hi,

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

YoussefBelloum
Esteemed Contributor

Re: histogram counts duplicates

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

katarzyna_wojci
New Contributor II

Re: histogram counts duplicates

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
Esteemed Contributor

Re: histogram counts duplicates

What is the expression you are using on the histogram ?

katarzyna_wojci
New Contributor II

Re: histogram counts duplicates

There is no expression. I just use one dimension field

YoussefBelloum
Esteemed Contributor

Re: histogram counts duplicates

So you can try on the Dimension:

=if(Flag='data1', your_dimension_field)

katarzyna_wojci
New Contributor II

Re: histogram counts duplicates

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
Esteemed Contributor

Re: histogram counts duplicates

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

Community Browser