Generate sample data:
SELECT 1 ID1, 1 ID2, 100 Amount FROM dual UNION ALL
SELECT 1 ID1, 2 ID2, 100 Amount FROM dual UNION ALL
SELECT 1 ID1, 3 ID2, 100 Amount FROM dual UNION ALL
SELECT 2 ID1, 1 ID2, 500 Amount FROM dual UNION ALL
SELECT 2 ID1, 2 ID2, 500 Amount FROM dual;
This is the current output in Qlik Sense:
ID1 | ID2 | Amount |
---|---|---|
Totals | 1,300 | |
1 | 1 | 100 |
1 | 2 | 100 |
1 | 3 | 100 |
2 | 1 | 500 |
2 | 2 | 500 |
The total amount should be based on ID1
, so it should be 600 only.
I tried using this formula to show the Amount
by following this answer.
Sum(Aggr(Sum(DISTINCT Amount), ID1))
But the resulting output displays the other amounts as 0 like this:
ID1 | ID2 | Amount |
---|---|---|
Totals | 600 | |
1 | 1 | 100 |
1 | 2 | 0 |
1 | 3 | 0 |
2 | 1 | 500 |
2 | 2 | 0 |
Expected output:
ID1 | ID2 | Amount |
---|---|---|
Totals | 600 | |
1 | 1 | 100 |
1 | 2 | 100 |
1 | 3 | 100 |
2 | 1 | 500 |
2 | 2 | 500 |