A
A
Alex2020-11-29 22:09:47
Google Sheets
Alex, 2020-11-29 22:09:47

How to create an empty string when there is no return data?

There is a QUERY query to several sheets of a table, where each sheet contains data for one month.
Example: =query({ '2020/01'!A1:F99; '2020/02'!A1:F99; '2020/03'!A1:F99}; " SELECT * WHERE (Col1 = "&J1&") ")

If the WHERE condition (search by ID) is met, then the requested data is returned and the table row is filled. All OK.
But in the case when there is no data for the required ID in the sheet / month, then there is nothing to return and the table is built with the skip of this month. How to make it so that if there is no data, the string is still created (empty or with zeros)? I tried to do something with the IF statement, but it didn't work.

Please tell me the solution. If it is not possible to do this within the framework of a QUERY query, then maybe you can come up with an additional construction (formula, additional query for already received data)?

Now it looks like this (2020/02 skipped):
ID | data | Date
21 | 45 | 2020/01
21 | 22 | 2020/03

And it needs to be like this:
ID | data | Date
21 | 45 | 2020/01
21 | 0 | 2020/02
21 | 22 | 2020/03

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ivanov, 2020-11-30
@freebird

Not the best solution, but you can try if the data structure will not change often
5fc7b08683c51408160522.png
Collect data
5fc7b12029493261083554.png
Take unique positions
5fc7b134523bd474857090.png
Take unique dates
5fc7b14611b07421562688.png
Build zero records with all possible combinations
5fc7b163014e4192309262.png
Select those that do not exist
5fc7b176c2d7f296501603.png
Example https://docs.google.com/spreadsheets/d /1kZWMci2QUa...

B
BasiC2k, 2020-11-30
@BasiC2k

Consider the option - create a list of dates without spaces in another way (manually, with a formula or a script) and drag the necessary data to the dates.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question