Is it possible for a label in a Google Sheets Query to be dynamic and utilize a variable for its value?

In QUERY, labels are typically assigned a static text value. For instance, you can use label Col2 'Total', which labels Column 2 as 'Total'.

However, when employing a dropdown menu for filtering results, the new label's value may be uncertain, especially if users cannot modify the query. Hence, is there a way to make label values dynamic?

For example, if Cell A1 has the text 'Total', could we replace label Col2 'Total' with the contents of Cell A1 as the label's value?

Specifically, if Cell A1 contains 'Grand Total', the output label would automatically update from 'Total' to 'Grand Total'.

Another approach is using Google Apps Script to automate and change your label based on values. Write a script that listens for changes in specific cells; when A1 updates, the script can retrieve that value and modify the label of your query dynamically within certain constraints. This method demands some js coding, though.