Search code examples
google-sheetsabsolutegoogle-query-language

ABS formula within a QUERY in Google Sheets


With the following Query: =QUERY(Transactions!$A$2:$N$300;"SELECT A, B, C, D, E, F, K, L, M, N")

I am trying to get the results from F and N to be absolute values while leaving the rest as is and I am having issues with the syntax of this line.

I tried a few options by adding {} and \ in the formula but I still keep getting a parsing error. It is probably an easy fix but I just do not know how to go about it.

Thanks!


Solution

  • Try ABS() is not recognized as QUERY() aggregation function. So, use ABS() for those columns (you want absolute value) then merge using either array notation {...} or using HSTACK() function. Try-

    =QUERY({A:C,INDEX(ABS(D:E))},"select *")
    

    Using HSTACK() function.

    =QUERY(HSTACK(A:C,INDEX(ABS(D:E))),"select *")
    

    enter image description here