Google sheets double query with selecting cell value as an explicit where condition












-1














I have the following dataset:



Start day   End Day Product ID  Sells   Unites
01/11/2018 08/11/2018 Blue DA_1000 $55,555.00 12
01/11/2018 08/11/2018 Red DA_1000 $1,321,321.00 55555
01/11/2018 08/11/2018 Blue DA_1000 $444.00 11111
01/11/2018 08/11/2018 Green DA_1000 $1,313,121.00 24
01/11/2018 08/11/2018 Aspire DA_1001 $11.00 55555
09/11/2018 16/11/2018 Black DA_1001 $786.13 49
09/11/2018 16/11/2018 Apple DA_1001 $629.55 22
09/11/2018 16/11/2018 White DA_1001 $0.39 1
17/11/2018 24/11/2018 Orange DA_1002 $0.00 515413
17/11/2018 24/11/2018 Blue DA_1002 $569.35 42
17/11/2018 24/11/2018 Red DA_1003 $315,154.00 40
25/11/2018 30/11/2018 White DA_1003 $45,464,564.00 36
25/11/2018 30/11/2018 Black DA_1003 $490.41 42
25/11/2018 30/11/2018 Vol DA_1004 $435.61 55


And I want to query from the products that have sells equal to=444, from this query I want to query again all of those that they're ID is equal to "DA_1000". and I managed to do that. But when I trying inserting to the where condition the explicit cell value I can't get any result,



This is the working query:



=query({query(A1:F15,"Select * Where E=444",1)},Select * Where Col4='DA_1000',1)


This is the non-working query:



=query({query(A1:F15,"Select * Where E=444",1)},Select * Where Col4='TEST!N6',1)


This is the url for the google sheet.



Please assist.










share|improve this question





























    -1














    I have the following dataset:



    Start day   End Day Product ID  Sells   Unites
    01/11/2018 08/11/2018 Blue DA_1000 $55,555.00 12
    01/11/2018 08/11/2018 Red DA_1000 $1,321,321.00 55555
    01/11/2018 08/11/2018 Blue DA_1000 $444.00 11111
    01/11/2018 08/11/2018 Green DA_1000 $1,313,121.00 24
    01/11/2018 08/11/2018 Aspire DA_1001 $11.00 55555
    09/11/2018 16/11/2018 Black DA_1001 $786.13 49
    09/11/2018 16/11/2018 Apple DA_1001 $629.55 22
    09/11/2018 16/11/2018 White DA_1001 $0.39 1
    17/11/2018 24/11/2018 Orange DA_1002 $0.00 515413
    17/11/2018 24/11/2018 Blue DA_1002 $569.35 42
    17/11/2018 24/11/2018 Red DA_1003 $315,154.00 40
    25/11/2018 30/11/2018 White DA_1003 $45,464,564.00 36
    25/11/2018 30/11/2018 Black DA_1003 $490.41 42
    25/11/2018 30/11/2018 Vol DA_1004 $435.61 55


    And I want to query from the products that have sells equal to=444, from this query I want to query again all of those that they're ID is equal to "DA_1000". and I managed to do that. But when I trying inserting to the where condition the explicit cell value I can't get any result,



    This is the working query:



    =query({query(A1:F15,"Select * Where E=444",1)},Select * Where Col4='DA_1000',1)


    This is the non-working query:



    =query({query(A1:F15,"Select * Where E=444",1)},Select * Where Col4='TEST!N6',1)


    This is the url for the google sheet.



    Please assist.










    share|improve this question



























      -1












      -1








      -1







      I have the following dataset:



      Start day   End Day Product ID  Sells   Unites
      01/11/2018 08/11/2018 Blue DA_1000 $55,555.00 12
      01/11/2018 08/11/2018 Red DA_1000 $1,321,321.00 55555
      01/11/2018 08/11/2018 Blue DA_1000 $444.00 11111
      01/11/2018 08/11/2018 Green DA_1000 $1,313,121.00 24
      01/11/2018 08/11/2018 Aspire DA_1001 $11.00 55555
      09/11/2018 16/11/2018 Black DA_1001 $786.13 49
      09/11/2018 16/11/2018 Apple DA_1001 $629.55 22
      09/11/2018 16/11/2018 White DA_1001 $0.39 1
      17/11/2018 24/11/2018 Orange DA_1002 $0.00 515413
      17/11/2018 24/11/2018 Blue DA_1002 $569.35 42
      17/11/2018 24/11/2018 Red DA_1003 $315,154.00 40
      25/11/2018 30/11/2018 White DA_1003 $45,464,564.00 36
      25/11/2018 30/11/2018 Black DA_1003 $490.41 42
      25/11/2018 30/11/2018 Vol DA_1004 $435.61 55


      And I want to query from the products that have sells equal to=444, from this query I want to query again all of those that they're ID is equal to "DA_1000". and I managed to do that. But when I trying inserting to the where condition the explicit cell value I can't get any result,



      This is the working query:



      =query({query(A1:F15,"Select * Where E=444",1)},Select * Where Col4='DA_1000',1)


      This is the non-working query:



      =query({query(A1:F15,"Select * Where E=444",1)},Select * Where Col4='TEST!N6',1)


      This is the url for the google sheet.



      Please assist.










      share|improve this question















      I have the following dataset:



      Start day   End Day Product ID  Sells   Unites
      01/11/2018 08/11/2018 Blue DA_1000 $55,555.00 12
      01/11/2018 08/11/2018 Red DA_1000 $1,321,321.00 55555
      01/11/2018 08/11/2018 Blue DA_1000 $444.00 11111
      01/11/2018 08/11/2018 Green DA_1000 $1,313,121.00 24
      01/11/2018 08/11/2018 Aspire DA_1001 $11.00 55555
      09/11/2018 16/11/2018 Black DA_1001 $786.13 49
      09/11/2018 16/11/2018 Apple DA_1001 $629.55 22
      09/11/2018 16/11/2018 White DA_1001 $0.39 1
      17/11/2018 24/11/2018 Orange DA_1002 $0.00 515413
      17/11/2018 24/11/2018 Blue DA_1002 $569.35 42
      17/11/2018 24/11/2018 Red DA_1003 $315,154.00 40
      25/11/2018 30/11/2018 White DA_1003 $45,464,564.00 36
      25/11/2018 30/11/2018 Black DA_1003 $490.41 42
      25/11/2018 30/11/2018 Vol DA_1004 $435.61 55


      And I want to query from the products that have sells equal to=444, from this query I want to query again all of those that they're ID is equal to "DA_1000". and I managed to do that. But when I trying inserting to the where condition the explicit cell value I can't get any result,



      This is the working query:



      =query({query(A1:F15,"Select * Where E=444",1)},Select * Where Col4='DA_1000',1)


      This is the non-working query:



      =query({query(A1:F15,"Select * Where E=444",1)},Select * Where Col4='TEST!N6',1)


      This is the url for the google sheet.



      Please assist.







      google-sheets google-sheets-query






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 at 15:52









      pushkin

      3,937112651




      3,937112651










      asked Nov 21 at 9:15









      Rapha

      34




      34
























          2 Answers
          2






          active

          oldest

          votes


















          0














          If you would want the select-clause in a cell (ex: H10) you'd have to write in this cell:



          ="Select * Where Col4='"&TEST!N6&"'"


          Then in your query:



          =query({query(A1:F15,"Select * Where E=444",1)},H10,1)


          Note that this can also be done in one query by writing in the reference cell



          =" and D='"&TEST!N6&"'"


          and then your query would look like this:



          =query(A1:F15,"Select * Where E=444"&H10,1)





          share|improve this answer





















          • This works, but this was a simplification. In a more complex query, aka: [SELECT P,Q,SUM(R),SUM(S),SUM(T),SUM(R)/SUM(S),SUM(R)/SUM(T),SUM(T)/SUM(S) GROUP BY P,Q order by Q] replacing the the part of the original: query(A1:F15,"Select * Where E=444",1). I can't seem to utilise the same concept
            – Rapha
            Nov 21 at 12:26





















          0














          Maybe:



          =query(A:F,"where E=444 and D contains 'DA_1000'")


          would serve.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408662%2fgoogle-sheets-double-query-with-selecting-cell-value-as-an-explicit-where-condit%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            If you would want the select-clause in a cell (ex: H10) you'd have to write in this cell:



            ="Select * Where Col4='"&TEST!N6&"'"


            Then in your query:



            =query({query(A1:F15,"Select * Where E=444",1)},H10,1)


            Note that this can also be done in one query by writing in the reference cell



            =" and D='"&TEST!N6&"'"


            and then your query would look like this:



            =query(A1:F15,"Select * Where E=444"&H10,1)





            share|improve this answer





















            • This works, but this was a simplification. In a more complex query, aka: [SELECT P,Q,SUM(R),SUM(S),SUM(T),SUM(R)/SUM(S),SUM(R)/SUM(T),SUM(T)/SUM(S) GROUP BY P,Q order by Q] replacing the the part of the original: query(A1:F15,"Select * Where E=444",1). I can't seem to utilise the same concept
              – Rapha
              Nov 21 at 12:26


















            0














            If you would want the select-clause in a cell (ex: H10) you'd have to write in this cell:



            ="Select * Where Col4='"&TEST!N6&"'"


            Then in your query:



            =query({query(A1:F15,"Select * Where E=444",1)},H10,1)


            Note that this can also be done in one query by writing in the reference cell



            =" and D='"&TEST!N6&"'"


            and then your query would look like this:



            =query(A1:F15,"Select * Where E=444"&H10,1)





            share|improve this answer





















            • This works, but this was a simplification. In a more complex query, aka: [SELECT P,Q,SUM(R),SUM(S),SUM(T),SUM(R)/SUM(S),SUM(R)/SUM(T),SUM(T)/SUM(S) GROUP BY P,Q order by Q] replacing the the part of the original: query(A1:F15,"Select * Where E=444",1). I can't seem to utilise the same concept
              – Rapha
              Nov 21 at 12:26
















            0












            0








            0






            If you would want the select-clause in a cell (ex: H10) you'd have to write in this cell:



            ="Select * Where Col4='"&TEST!N6&"'"


            Then in your query:



            =query({query(A1:F15,"Select * Where E=444",1)},H10,1)


            Note that this can also be done in one query by writing in the reference cell



            =" and D='"&TEST!N6&"'"


            and then your query would look like this:



            =query(A1:F15,"Select * Where E=444"&H10,1)





            share|improve this answer












            If you would want the select-clause in a cell (ex: H10) you'd have to write in this cell:



            ="Select * Where Col4='"&TEST!N6&"'"


            Then in your query:



            =query({query(A1:F15,"Select * Where E=444",1)},H10,1)


            Note that this can also be done in one query by writing in the reference cell



            =" and D='"&TEST!N6&"'"


            and then your query would look like this:



            =query(A1:F15,"Select * Where E=444"&H10,1)






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 21 at 11:14









            JPV

            10.6k21525




            10.6k21525












            • This works, but this was a simplification. In a more complex query, aka: [SELECT P,Q,SUM(R),SUM(S),SUM(T),SUM(R)/SUM(S),SUM(R)/SUM(T),SUM(T)/SUM(S) GROUP BY P,Q order by Q] replacing the the part of the original: query(A1:F15,"Select * Where E=444",1). I can't seem to utilise the same concept
              – Rapha
              Nov 21 at 12:26




















            • This works, but this was a simplification. In a more complex query, aka: [SELECT P,Q,SUM(R),SUM(S),SUM(T),SUM(R)/SUM(S),SUM(R)/SUM(T),SUM(T)/SUM(S) GROUP BY P,Q order by Q] replacing the the part of the original: query(A1:F15,"Select * Where E=444",1). I can't seem to utilise the same concept
              – Rapha
              Nov 21 at 12:26


















            This works, but this was a simplification. In a more complex query, aka: [SELECT P,Q,SUM(R),SUM(S),SUM(T),SUM(R)/SUM(S),SUM(R)/SUM(T),SUM(T)/SUM(S) GROUP BY P,Q order by Q] replacing the the part of the original: query(A1:F15,"Select * Where E=444",1). I can't seem to utilise the same concept
            – Rapha
            Nov 21 at 12:26






            This works, but this was a simplification. In a more complex query, aka: [SELECT P,Q,SUM(R),SUM(S),SUM(T),SUM(R)/SUM(S),SUM(R)/SUM(T),SUM(T)/SUM(S) GROUP BY P,Q order by Q] replacing the the part of the original: query(A1:F15,"Select * Where E=444",1). I can't seem to utilise the same concept
            – Rapha
            Nov 21 at 12:26















            0














            Maybe:



            =query(A:F,"where E=444 and D contains 'DA_1000'")


            would serve.






            share|improve this answer


























              0














              Maybe:



              =query(A:F,"where E=444 and D contains 'DA_1000'")


              would serve.






              share|improve this answer
























                0












                0








                0






                Maybe:



                =query(A:F,"where E=444 and D contains 'DA_1000'")


                would serve.






                share|improve this answer












                Maybe:



                =query(A:F,"where E=444 and D contains 'DA_1000'")


                would serve.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 21 at 15:21









                pnuts

                47.6k76195




                47.6k76195






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408662%2fgoogle-sheets-double-query-with-selecting-cell-value-as-an-explicit-where-condit%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Feedback on college project

                    Futebolista

                    Albești (Vaslui)