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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
KarlaB
Contributor
Contributor

Sum only not duplicated values

Hi!

I have some "projected expenditures" with an ID ($), some of them have been purchased so they have same $ (but -$) and same ID.

Now i want to sum the budget of the pending expenses (without the duplicated ID's, cause they have already been done).

Captura de pantalla 2023-01-26 093701.png

For example, i want Qlik to show me done USD as sum(USD from duplicated id)[Red ones] and pending USD as sum(USD from not duplicated id) [White ones]

 

Note: I wouldn't like to base on duplicated amount USD, cause we can have some purchases with the same cost, so they would not be displayed, that's why i want to base on ID

 

Labels (1)
1 Reply
QFabian
MVP
MVP

Hi @KarlaB , please check this example.

 

//Script

Data:
Load * INLINE [
Account, USD, ID
Projected, 125, 123000
Projected, 948, 123001
Projected, 283, 123002
Projected, 9485, 123003
Projected, 28, 123004
Projected, 938, 123005
Expenses, -283, 123002
Expenses, -28, 123004
];

Data2:
Load
Account,
ID,
if(ID = previous(ID), 'Done', 'Pending') as State,
USD
Resident Data
Order by
ID,
USD desc;

drop table Data;
exit script;

QFabian_0-1674753009492.png

Done : Sum({<State= {'Done'}>} USD)

Pending : Sum({<Account= {'Projected'}>} USD) + Sum({<State= {'Done'}>} USD)

 

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.