2

I'm trying to get a random meal planner set up and am stuck on getting this error message, "Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: A" on this piece of code

=QUERY({Curries!A2:D;Soups!A2:D;Pasta!A2:D;Casseroles!A2:D},"Select A,C where C <= "& C4 &" Order by D desc Limit 5")

Any advice would be appreciated.

player0
  • 124,011
  • 12
  • 67
  • 124
Pikie
  • 23
  • 5
  • You can only use `A`, `B`, etc when you are directly referencing the ranges. `QUERY(Curries!A2:D, "select A,C where C <= "&C4&" order by D desc limit 5")` – 2pichar Apr 27 '22 at 17:00

1 Answers1

1

use Col references:

=QUERY({Curries!A2:D; Soups!A2:D; Pasta!A2:D; Casseroles!A2:D},
 "select Col1,Col3 where Col3 <= "&C4&" order by Col4 desc limit 5")
player0
  • 124,011
  • 12
  • 67
  • 124
  • Is there a way to edit this to make it so the selected numbers are going to =14? – Pikie Apr 27 '22 at 17:18
  • @Pikie you mean `"select Col1,Col2,Col3,...,Col14"` ? – player0 Apr 27 '22 at 17:21
  • No, the colums are giving me multiple numbers (servings of food per meal) that need to each be under or equal to 14, but is there a way to make it so the total servings is equal to 14? – Pikie Apr 27 '22 at 17:23
  • @Pikie can you share a copy / sample of your sheet with an example of the desired output? – player0 Apr 27 '22 at 17:26
  • Of course. [link](https://docs.google.com/spreadsheets/d/1hvmHBB6R-jGVrbWMRLIihuMopAopaz14CUAhVkJ-R6A/edit?usp=sharing), so I'd like it to be so the total servings is always 14 when choosing randomly from the meal options – Pikie Apr 27 '22 at 17:29