0

I was able to learn some through google and built a formula to flatten, transpose and query data into a new database style format. Unformatately, my ID column has numbers and IDs with letters. So, due to Query's rules, it only copies over the ID column numberic values and leaves the columns with IDs with letters blank. I tried to add the TO_TEXT to the formual, but, unfortunately that then cements my Colum 4 nad 5 (month and amount) to text and I cannot manually reformat those columns.

formula missing the IDs with text

adding TO_TEXT makes month and amount hard coded text

Is there a way to only convert the first column using TO_TEXT or simply just another way to do this? I need to be able to copy all IDs (both numberic and text) AND also keep the Month and Amount columns are their respective formats.

Data file for reference. I'm taking data from tab 'WD4' and reformatting it to tested formulas on Sheet2 https://docs.google.com/spreadsheets/d/18iTqOqlC3_zw81mO74n2Jn42HTEmiIc2_GOoaoje_Pw/edit?usp=sharing

My original query:

  =ARRAYFORMULA(
   QUERY(
     SPLIT(
        FLATTEN(
           TRANSPOSE(QUERY(TRANSPOSE('WD4'!F6:H30&"||"),,9^9))&"||"&'WD4'!J3:U3&"||"&'WD4'!J6:U1002
        ),"||"
     ),
   "SELECT Col2, Col3, Col1, Col4, Col5 where Col5 is not null AND Col4 is not null AND Col1 is not null order by Col3 label Col2 'ID', Col1 'Rev Type', Col3 'Customer', Col4 'Month', Col5 'Amount'")
) 

And then my query when I add TO_TEXT

    =ARRAYFORMULA(
   QUERY(TO_TEXT(
     SPLIT(
        FLATTEN(
           TRANSPOSE(QUERY(TRANSPOSE('WD4'!F6:H30&"||"),,9^9))&"||"&'WD4'!J3:U3&"||"&'WD4'!J6:U1002
        ),"||"
     )),
   "SELECT Col2, Col3, Col1, Col4, Col5 where Col5 is not null AND Col4 is not null AND Col1 is not null order by Col3 label Col2 'ID', Col1 'Rev Type', Col3 'Customer', Col4 'Month', Col5 'Amount'")
)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.