Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9628

Arrayformula to Query Sum

$
0
0

Good day,

I am trying to run a query that returns the sum of a column based on the query key and have it displayed as an array so that each sum is visible. With my below formula, I am successful.

```=ARRAYFORMULA(query (I27:AN," select COUNT(J), COUNT(K), COUNT(L), COUNT(M), COUNT(N), COUNT(O), COUNT(P), COUNT(Q), COUNT(R), COUNT(S), COUNT(T), COUNT(U), COUNT(V), COUNT(W), COUNT(X), COUNT(Y), COUNT(Z), COUNT(AA), COUNT(AB), COUNT(AC), COUNT(AD), COUNT(AE), COUNT(AF), COUNT(AG), COUNT(AH), COUNT(AI), COUNT(AJ), COUNT(AK), COUNT(AL), COUNT(AM), COUNT(AN) where I matches 'PR1' LABEL COUNT(J)'', COUNT(K)'', COUNT(L)'', COUNT(M)'', COUNT(N)'', COUNT(O)'', COUNT(P)'', COUNT(Q)'', COUNT(R)'', COUNT(S)'', COUNT(T)'', COUNT(U)'', COUNT(V)'', COUNT(W)'', COUNT(X)'', COUNT(Y)'', COUNT(Z)'', COUNT(AA)'', COUNT(AB)'', COUNT(AC)'', COUNT(AD)'', COUNT(AE)'', COUNT(AF)'', COUNT(AG)'', COUNT(AH)'', COUNT(AI)'', COUNT(AJ)'', COUNT(AK)'', COUNT(AL)'', COUNT(AM)'', COUNT(AN)''"))```

enter image description here

However, I experience an oddity when using this formula when I manipulate the data on the first query row only.

If I remove the data in one of the cells in the first row of the query range for example J27, the correct result is displayed and the count for that column is reduced by 1.

enter image description here

Now the oddity, if I remove the data in a second cell anywhere in the row, the entire query result is change, and is reduced by 1 for each column. It even adjusts the Daily Hours totals which are not tied to the query results themselves, but rather a total of another query.

enter image description here

```=ARRAYFORMULA(query (I27:AN," select SUM(J), SUM(K), SUM(L), SUM(M), SUM(N), SUM(O), SUM(P), SUM(Q), SUM(R), SUM(S), SUM(T), SUM(U), SUM(V), SUM(W), SUM(X), SUM(Y), SUM(Z), SUM(AA), SUM(AB), SUM(AC), SUM(AD), SUM(AE), SUM(AF), SUM(AG), SUM(AH), SUM(AI), SUM(AJ), SUM(AK), SUM(AL), SUM(AM), SUM(AN) where I matches 'PR1|PR2|PR3|PR4|DE1|DE2|DE3|O/T CITY|COE T' LABEL SUM(J)'', SUM(K)'', SUM(L)'', SUM(M)'', SUM(N)'', SUM(O)'', SUM(P)'', SUM(Q)'', SUM(R)'', SUM(S)'', SUM(T)'', SUM(U)'', SUM(V)'', SUM(W)'', SUM(X)'', SUM(Y)'', SUM(Z)'', SUM(AA)'', SUM(AB)'', SUM(AC)'', SUM(AD)'', SUM(AE)'', SUM(AF)'', SUM(AG)'', SUM(AH)'', SUM(AI)'', SUM(AJ)'', SUM(AK)'', SUM(AL)'', SUM(AM)'', SUM(AN)''"))```

More over, I use the exact same formula for other query keys, PR2, PR3, PR4 directly below and the results work perfectly, no matter the amount of cells data is removed from.

This oddity seems to only occur with the query on the first query row.

Any help or insight would be greatly appreciated.

I have included a test sheet that replicates my issue. I have highlighted the row which the oddity occurs.

https://docs.google.com/spreadsheets/d/1EzFGg6MdI9qiQWHT58TTK2B53DiQl2vqXc632vLWdSE/edit?usp=sharing


Viewing all articles
Browse latest Browse all 9628

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>