Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover the Trends Shaping AI in 2026: Register Here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

set analysis

Hi All,

I have the pulled the below information from my database. The below have 2 types Invoce and recovery . Currently the database saves both as +ve.

provideraccountsptypesum(spamount)
abcpqe201110Invoice1143.8132
abcpqe201111Invoice1143.8132
abcpqe201112Recovery1143.8132
abcpqe201112Recovery946.118

I am trying to have an expression which can save the recovery as positive value and invoice as negative. Can any one please help me with the expression using set analysis.

Appreciate your time for reading the question and thanks in advance for helping.

Regards

Viral

1 Solution

Accepted Solutions
jpapador
Partner - Specialist
Partner - Specialist

I would use an if statement instead of set analysis.

If(Type = 'Invoice', Sum(spamount) * -1, Sum(spamount))

Alternativley you could also in the load script do the same thing.

If(Type = 'Invoice', spamount * -1, spamount) as NewAmountName

View solution in original post

2 Replies
jpapador
Partner - Specialist
Partner - Specialist

I would use an if statement instead of set analysis.

If(Type = 'Invoice', Sum(spamount) * -1, Sum(spamount))

Alternativley you could also in the load script do the same thing.

If(Type = 'Invoice', spamount * -1, spamount) as NewAmountName

swuehl
MVP
MVP

Maybe

=sum({<type = {Recovery}>} spamount) - sum({<type = {Invoice}>} spamount)

But why not store the data accordingly when loading in:

LOAD

     if(type = 'Invoice', -1 * spamount, spamount) as spamount,

     ...