google-sheetsgoogle-sheets-formulaspreadsheet

QUERY + BYROW + LAMBDA display dates as raw numbers instead of the original values


I have two sheets in the same spreadsheet:

  1. A "database" with a list of events, each row containing infos like the date, event name & assignee

  2. A "view" where I want to display a list of all events assigned to a specific person, with the date & name of each event

I also want the results to be concatenated in a single cell instead of spanning multiple rows like QUERY() does by default.

I've managed to achieve what I want, with the only problem being that in the concatenated result the dates that have been queried from the "database" sheet are displayed as raw numbers and not as formatted values like their original value!

Here's a screenshot illustrating what I mean:

A screenshot showing the formula I'm using, along with expected and actual results.

And here's the formula I'm using:

=JOIN(CHAR(10); BYROW(QUERY('Programme local'!A:E; "SELECT A, D WHERE B MATCHES '.*\b" & A$1 & "\b.*'"; 0); LAMBDA(row; JOIN(" - "; row))))

I've tried adding FORMAT A 'dd-MMM-yyyy' to the QUERY() to force formatting but no changes.


Solution

  • Use to_text(), like this:

    =join(char(10), 
      filter( 
        to_text('Programme local'!A1:A) & " - " & 'Programme local'!D1:D, 
        regexmatch('Programme local'!B1:B, "\b" & A1 & "\b") 
      ) 
    )
    

    See to_text() and Working with date and time values in Google Sheets.