Search code examples
google-sheets

IF AND function for entire columns in Google Sheets


Apologies in advance if this is ridiculously simple, but I can't seem to get it to work.

I have a Google sheet that is constantly updated with new data which is displayed in three columns (url, date, sessions). I'd like to create a new tab into which I pull this data across. I can't pull in specific cells because the data is constantly changing, so am trying to come up with a specific formula that will do the job for me.

=IF(AND('raw data'!A:A="url", 'raw data'!B:B="date"),'raw data'!C:C,"NO DATA")

As far as I can tell, the above query should pull the number of sessions for a specific page on a specific date, but I constantly seem to be getting "NO DATA" returned. In case it's not clear, I'd like to be able to get the value for CX where AX=url and BX=date.

Any pointers would be greatly appreciated.


Solution

  • First and foremost, thanks for the help/suggestions. For anybody who stumbles upon this in the future, I ended up using the formula below, though it's possible that some of the other suggestions would have also done the job.

    The C column on the raw data sheet contains the number of sessions of each page (ie, the data I was trying to pull across) while the C column of the new tab contains the URL (which is in column A on the raw data sheet). Column B of the raw data sheet is the date. I originally tried to use a cell in the new tab to check for the date (ie, "D1='raw data'B:B", where D1 was a cell containing the date I wanted the data for), but found that this caused major issues when sorting the data on the new tab and made it impossible to copy the formula across cells, so ended up using the TODAY function instead.

    =INDEX('raw data'!C:C,MATCH(1,(C1='raw data'!A:A)*(TODAY()-1='raw data'!B:B),0))