Saturday, September 15, 2012

Query function and drop down list

Query function using drop down list to select data from table


Question:



I'm trying to have a drop down list be where you choose what query to run.



Code        Product          Total Sales
A              A                   100
B              B                   200
C              C                   300

What I want to do is I put in a drop down list with the options in it like top seller, top product, etc.then when I choose an option, the chosen query will be run on that sheet, displaying the required data?


Solution:

You have to create drop down list in Cell E1 and then put the following formula in Cell F1:
=if(E1="Top seller";query(A2:C;"select A where C=" & max(C2:C));if(E1="Top Product";query(A2:C;"select B where C=" & max(C2:C));))

Have a look at the following screenshot:



Now when you change the value in the drop down list in Cell E1:



You will get the updated result in Cell F1:





I hope the above solution will help you, and if you need more help then please do comment below on this blog itself, I will try to help you out.

If this blog post was helpful to you, and if you think you want to help me too and make my this blog survive then please donate here: http://igoogledrive.blogspot.com/2012/09/donate.html 

Thanks,
Kishan,

No comments:

Post a Comment