GOOGLE SHEETS: Help with my Query formula?

BadFish523

Board Regular
Joined
Feb 15, 2018
Messages
56
=IF(A2="Work Instructions",QUERY(Data!A2:N,<wbr>"select D where E='"&C2&"' and F='"&E2&"'"),IF(A2="Standard Work",QUERY(Data!A2:N,"select D where H='"&C2&"' and I='"&E2&"')")))

I'm trying to build a query that can be manipulated a little bit. What I want is for it to query (sheet'Data') columns e and f when box A2 says Work Instructions but I want it to query columns (sheet 'Data') h and i when box A2 says Standard Work. Anybody know how to do this?

Edit: Forgot to add the first part of the query works fine. Only when I change A2 to Standard Work does it not work.
 
Last edited:

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Re: Help with my Query formula?

I am not aware of any QUERY function in Excel.
Is it part of an Add-In or is it a User Defined Function?
 
Upvote 0
Re: Help with my Query formula?

I am not aware of any QUERY function in Excel.
Is it part of an Add-In or is it a User Defined Function?
Oh man, my bad. I forgot to post I'm using Google Sheets. I just figured out my issue though. I had an extra parenthesis in my formula. Should look like this (minus the red parenthesis) and it will work:
=IF(A2="Work Instructions",QUERY(Data!A2:N,<wbr>"select D where E='"&C2&"' and F='"&E2&"'"),IF(A2="Standard Work",QUERY(Data!A2:N,"select D where H='"&C2&"' and I='"&E2&"')")))
 
Upvote 0
Re: Help with my Query formula?

OK. Glad you figured it out.

I moved your question to the "General Excel & Other Discussion Questions" forum, as that is the best place to post Google Sheet questions.
I also added it to the title of the post (you will want to be sure to mention somewhere that it is for "Google Sheets").
 
Upvote 0

Forum statistics

Threads
1,215,012
Messages
6,122,682
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top