Getting tags used per category

Ahh, good point, @randy. I hadn’t considered multiple tags in a transaction…

After thinking it over more, I have a basic functioning formula that will create a table of summed Amounts for one Tag per row and Category per column. This works with the Foundation sheet with a Tags column added between Categorized Date and Date Added. I still need to replace the direct column references with INDIRECT lookups. A WHERE clause for Category MATCHES and Tag MATCHES can easily be added, but I still need to come up with an efficient way to do a multi-select of categories and tags aside from a long list of data validation drop-downs. There are some columns I can also trim from the inner query. This is a start at least.

=QUERY(INDEX(QUERY(SPLIT(FLATTEN(Transactions!B2:B&"|"&Transactions!C2:C&"|"&Transactions!E2:E&"|"&Transactions!F2:F&"|"&SPLIT(Transactions!Q2:Q,",",)),"|"),"WHERE Col5 IS NOT NULL")),"SELECT Col5,SUM(Col4) GROUP BY Col5 PIVOT Col3 LABEL Col5 'Tag'")

This formula effectively splits single transactions with multiple tags into multiple transactions with a single tag and then queries that virtualized transaction table with a pivot to get the desired result. Theoretically it will work with any number of tags and categories.

Foundation Transactions with sample data:

QUERY with PIVOT on Category, one Tag per row:

1 Like