Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Specialist III
Specialist III

Try the following expression

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

View solution in original post

3 Replies
Gysbert_Wassenaar

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
Author

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
Specialist III
Specialist III

Try the following expression

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