Sarah Borja
Sarah Borja

Reputation: 3

Merge 2 sheets and add a column for the name of the data source

I am trying to combine 2 sheets for now all data columns are rows are needed and they have the same format and column headers, but in the final data I need to add a date in column A which 1st data is from 2024-07-01 and the other sheet is 2024-08-01 in date format. How can I combine them?

Here's the formula that works so far and I need column A to be the dates: =QUERY({july_data!A2:K;aug_data!A2:K},"select * where Col1 <>''")

Thanks.

I have tried the following formulas but I can't show the name for the rows:

=QUERY({july_data!A2:K;aug_data!A2:K},"select * where Col1 <>''")

=QUERY({"2024-07-01", july_data!A2:K};{"2024-08-01",aug_data!A2:K}},"select * where Col1 <>''")

Upvotes: 0

Views: 27

Answers (1)

rockinfreakshow
rockinfreakshow

Reputation: 30240

You may try:

=QUERY({let(Σ,july_data!A2:K,{wrapcols("2024-07-01",rows(Σ),"2024-07-01"),Σ});
        let(Σ,aug_data!A2:K,{wrapcols("2024-08-01",rows(Σ),"2024-08-01"),Σ})},
 "where Col2 is not null")

Upvotes: 0

Related Questions