samedi 21 avril 2018

Using where IF within query function of Google Sheets

I have a data set that is a list of security types and I've added some additional columns for replacement securities. I'm trying to get the results of my query function to reflect both the count of types of securities and the sum of their values. Here's what I have currently...

=QUERY(HoldingsData,"select K, count(K), sum(F) where L<> 'Sell' OR L='Sell' AND N=K group by K)

The columns breakdown that I'm using are as: K is Existing Type, F is Value, L is Sell Instruction, N is Replacement security type

This works great if the replacement security matches the existing in type. But I need the resulting count and sum to reflect the NEW type if Col(L) = Sell.

I've attempted to nest an IF function in the query with no success. Any ideas? TIA!

Aucun commentaire:

Enregistrer un commentaire