Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I´m quite new with Qlik and struggling with an expression. I´m trying to sum distinct ServiceLines per InvoiceNo whenever FlagMatched has a value.
if((FlagMatched=1), sum(aggr(sum(DISTINCT ServiceLines), InvoiceNo)),0)
I have to use Distinct Service lines since the data has several updates for each matched invoice.
InvoiceNo | ServiceLines | FlagMatched |
001 | 2 | 0 |
001 | 2 | 0 |
002 | 4 | 1 |
002 | 4 | 1 |
003 | 6 | 0 |
003 | 6 | 0 |
004 | 8 | 1 |
004 | 8 | 1 |
In this case the result what I´m after is 4+8=12
For some reason I´m getting the correct value with below expression when using filter FlagMatched=1 in GUI but as soon as I take it out, I don´t get any results.
All the tips are welcome!
Try this:
sum(aggr(sum(DISTINCT if(FlagMatched=1, ServiceLines)), InvoiceNo)),0)
Many thanks! Got it working with slight change to the expression
sum(aggr(sum(DISTINCT if(FlagMatched=1, ServiceLines,0)), InvoiceStatusKey))