[英]select data from a table with a dropdown
I have a very big table where I add a column every month with new prices. 我有一张很大的桌子,每个月我都会在其中添加新价格列。 Then, I have to perform some analysis with those values.
然后,我必须使用这些值进行一些分析。 I have already made it but with the name of the column in the formula.
我已经做到了,但是在公式中使用了列名。 I want to know if I can point the formula to the drop-down so I just select the new period when it is available and get the results.
我想知道是否可以将公式指向下拉菜单,所以我只选择可用的新期间并获取结果。
Here are some examples of the formulas I have been using: 这是我一直在使用的一些公式示例:
{=SUM(IF($B17=Matriz[money];Matriz[31-10-2013]*Matriz[country];0))}
I would like to use something like 我想使用类似
{=SUM(IF($B17=Matriz[money];Matriz[*dropdow reference*]*Matriz[country];0))}
pd: the { }
are for matrix calculations (when you use ctrl + shift + enter) pd:
{ }
用于矩阵计算(使用ctrl + shift + enter时)
You are looking for the indirect
function. 您正在寻找
indirect
功能。 With it, you can construct a string on the fly that contains your cell formula - then the indirect function will resolve the formula-string to its result. 有了它,您可以即时构造一个包含单元格公式的字符串-然后,间接函数会将公式字符串解析为其结果。
A bit difficult to describe without a concrete example. 没有具体的例子很难描述。
Have a look at the following resources: 看一下以下资源:
http://www.cpearson.com/excel/indirect.htm http://www.cpearson.com/excel/indirect.htm
I suggest you to use INDEX
+ MATCH
instead IDIRECT
(since IDIRECT
is volatile function and your formula would be recalculated each time any cell changed): 我建议您使用
INDEX
+ MATCH
代替IDIRECT
(因为IDIRECT
是易失函数,每次更改任何单元格都会重新计算您的公式):
=SUM(IF($B17=Matriz[money];INDEX(Matriz[#Data];0;MATCH(A1;Matriz[#Headers];0))*Matriz[country];0))
and press CTRL + SHIFT + ENTER to evaluate it. 然后按CTRL + SHIFT + ENTER进行评估。
alternatively you could use SUMPRODUCT
- it doesn't require array entry: 或者,您可以使用
SUMPRODUCT
它不需要数组输入:
=SUMPRODUCT(($B17=Matriz[money])*INDEX(Matriz[#Data];0;MATCH(M2;Matriz[#Headers];0))*Matriz[country])
I assumed that your dropdown value is in A1
cell. 我假设您的下拉值位于
A1
单元格中。
MATCH(A1;Matriz[#Headers];0)
finds value from A1
cell in headers of your table MATCH(A1;Matriz[#Headers];0)
从表头中的A1
单元中查找值 INDEX(Matriz[#Data];0;MATCH(A1;Matriz[#Headers];0))
gets corresponding column of data INDEX(Matriz[#Data];0;MATCH(A1;Matriz[#Headers];0))
获得相应的数据列
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.