Search code examples
google-sheetsgoogle-sheets-formula

In Sheets, query formula with numerous columns range, but only one with a treatment on it


I would like to import, with a query formula, a range of data : O5:Q8. In this range of data, I want to do a treatment on the P column without changing the master data, but only in the result of the query, and to import O and Q columns data unchanged. Having all in one query, to allow me to filter it easily later.

So from this data range :

date text number
30/12/2022 Café 2
01/12/2022 trÉs choûetté 10
02/12/2022 àéïôù 7
03/12/2022 É 3

I would like to obtain :

date text number
30/12/2022 Cafe 2
01/12/2022 trEs chouette 10
02/12/2022 aeiou 7
03/12/2022 E 3

The formula that modifies correctly the P column is this one :

=map(P5:P8;lambda(Σ;if(Σ="";;index(let(Δ;mid(Σ;sequence(len(Σ));1);
           join(;map(Δ;lambda(Λ;xlookup(1;--exact(R2:R342;Λ);S2:S342;Λ)))))))))

It comes from this topic : In a google sheets query, replace all diacritic caracters with a formula

But I can't figure out how to, using just only one query formula, import O P and Q columns treating P column data without changing O and Q columns.

The query I have for now is :

=QUERY({O5:O8;Q5:Q8;map(P5:P8;lambda(Σ;if(Σ="";;index(let(Δ;mid(Σ;sequence(len(Σ));1);
           join(;map(Δ;lambda(Λ;xlookup(1;--exact(R2:R342;Λ);S2:S342;Λ)))))))))};"select *")

But the result is in only one column and twice the length of my range :

30/12/2022

01/12/2022

02/12/2022

04/12/2022

01/01/1900

09/01/1900

06/01/1900

02/01/1900

What query formula could do what I want it to do ?

Thanks


Solution

  • You may use:

    =QUERY({O5:O8\
            map(P5:P8;lambda(Σ;if(Σ="";;index(let(Δ;mid(Σ;sequence(len(Σ));1);join(;map(Δ;lambda(Λ;xlookup(1;--exact(R2:R342;Λ);S2:S342;Λ)))))))))\
            Q5:Q8};"select *")
    

    enter image description here