qlikviewqliksenseqlik-expression

Qlik Sense Sum of One field based on unique value of other fields


Sample Data:

    P   Q    R
    1   A    3
    1   A    3
    1   A    2
    1   B    5
    1   C    7
    2   A    3
    2   A    3

Expected Output:

P   Q    R
1   A    5
1   B    5
1   C    7
2   A    3
    

i Have tried this Sum (Distinct R) but it is not working. i need to group by P and Q column and add Unique Value of R for that. Please support


Solution

  • In chart, you have to add P and Q fields as dimensions. Then your expression should work just fine.

    In script your code should look like this:

    Load P, Q, Sum( Distinct R ) as sum_of_R
    FROM sample_data
    Group By P, Q;