Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google spreadsheet select a column with substring

I have a spreadsheet A, and use import/query command to generate a spreadsheet B, but I wish the selected column display only first 7 characters.

e.g. A has a 1234567890abcdef string, but after apply the select command such as:

=query(importrange("docid","sheetname!A:M"),"select Col1")

Then wish the output is 1234567 (first 7 characters) but not the whole string 1234567890abcdef.

I wish below command can work but actually not:

=query(importrange("docid","sheetname!A:M"),"select left(Col1,7)")

1 Answers

try wrapping the left function around the query, like:

=Arrayformula(Left(query(importrange("docid","sheetname!A:M"),"select Col1"),7))
like image 167
JPV Avatar answered Apr 18 '26 13:04

JPV