Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Not applicable

Sum total negative margin of a total invoice.

Hi Guys,

I'm new to qlikview.

I'm trying to sum the total negative margin and group that by invoice.

So the result I'm after is the total negative margin of the total invoice.

I tried using the following expression;

sum({<margin={"<0"}>} margin)

however using this expression It is summing the total negative margins line by line rather than the total of the invoice where it is a negative margin.

1 Solution

Accepted Solutions
nagaiank
Valued Contributor III

Re: Sum total negative margin of a total invoice.

Try the following expression

=Sum(If(Aggr(Sum(margin),InvoiceId) < 0, Aggr(Sum(margin),InvoiceId),0))

3 Replies

Re: Sum total negative margin of a total invoice.

Try something like this: sum({<margin={"<0"}>} total <invoice_id> margin). Replace invoice_id with the name of your invoice dimension.


talk is cheap, supply exceeds demand
Not applicable

Re: Sum total negative margin of a total invoice.

Hi Thanks for your response,

unforunately the expression you suggested gives me the exact same result as the one I was orginally using.

Although your expression looked like it would work, It still gives me the same result

What I'm trying to do is for example if I have 5000 invoices, I want to sum the margin of the negative margin invoices as a total not a negative margin of a particular line within that invoice.

Thanks for your help

nagaiank
Valued Contributor III

Re: Sum total negative margin of a total invoice.

Try the following expression

=Sum(If(Aggr(Sum(margin),InvoiceId) < 0, Aggr(Sum(margin),InvoiceId),0))

Community Browser