admin管理员组文章数量:1122846
In QUERY
, labels can be created with a text value. Example: label Col2 'Total'
This will display "Total" instead of the existing label for Column 2.
But what if the query uses a dropdown as a means of filtering the results. In this case, the value of a "new" label might not be predictable and an end user might not be able/permitted to edit the query. So, can a label value be dynamic?
Say Cell A1 contains the word "Total".
Instead of writing label Col2 'Total'
, is it possible to substitute the value of cell A1 as the new label value?
For instance, if Cell A1 = "Grand Total", the label would change from "Total" to "Grand Total".
In QUERY
, labels can be created with a text value. Example: label Col2 'Total'
This will display "Total" instead of the existing label for Column 2.
But what if the query uses a dropdown as a means of filtering the results. In this case, the value of a "new" label might not be predictable and an end user might not be able/permitted to edit the query. So, can a label value be dynamic?
Say Cell A1 contains the word "Total".
Instead of writing label Col2 'Total'
, is it possible to substitute the value of cell A1 as the new label value?
For instance, if Cell A1 = "Grand Total", the label would change from "Total" to "Grand Total".
Share Improve this question asked Nov 22, 2024 at 2:12 TedinozTedinoz 7,8763 gold badges28 silver badges39 bronze badges 2- I'm surprised you didn't know this. – TheMaster Commented Nov 22, 2024 at 6:29
- @TheMaster You're not the only one :) Actually I did try this (no, truly) but I must have mucked up the syntax so I didn't think this worked with labels; hence the question (sigh). – Tedinoz Commented Nov 22, 2024 at 9:47
1 Answer
Reset to default 0Concatenating a range in a Query as a label
Formula:
=QUERY(A2:B7, "SELECT A, SUM(B) GROUP BY A LABEL SUM(B) '" & C1 & "'")
Changing the value in C1
instantly updates the column label in the result.
Instead of hardcoding the formula use the &
operator to dynamically refer to the value in C1
or your desired cell.
Sample Output:
Note: I just created sample data to demonstrate how to reference another cell.
本文标签: Can a label in a Google Sheets Query be dynamic can it reference a variableStack Overflow
版权声明:本文标题:Can a label in a Google Sheets Query be dynamic; can it reference a variable? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736306077a1932822.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论