excel - INDEX returns wrong value and no value
问题描述
I'm trying to find matching values and sort them in a column.
Column A contains Names and Column B Training Done by person in Column A.
An example of my data can be seen here:
Having that data, I want to get a separate table with two Columns(Name and training). In Column C, I want the names and in Column D I want the training done by who is in Column C.
=IFERROR(INDEX($B$2:$B$7,SMALL(IF($C2=$A$2:$A$7,ROW($A$2:$A$7)-1,""),ROWS($D$1:D1))),"No training done")
I've tried using the above formula, but it seems to only work for the first entry in the table. I can't figure out what i should change.
This is what I get
It shows "No training done" to people who have had training and there's a "0" where it should be "No training done".
This is my expected result:
L.E : Anna did Excel. A mistake on my part in the above picture.
Also, I'm only interested in the Training Column, as I already got the hang of the formula to order the names.
Thank you.
解决方案
=INDEX(Training,AGGREGATE(15,6,1/(C2=Names)*ROW(Names),COUNTIF($C$2:$C2,$C2))-1)
在这种情况下,我使用了自定义格式的结果:;;"No Training Done";@
但是,如果您不介意更长的公式,您可以使用IF
函数No Training Done
在公式不返回任何内容的情况下返回语句。
=IF(INDEX(Training,AGGREGATE(15,6,1/(C2=Names)*ROW(Names),COUNTIF($C$2:$C2,$C2))-1)=0,"No Training Done",INDEX(Training,AGGREGATE(15,6,1/(C2=Names)*ROW(Names),COUNTIF($C$2:$C2,$C2))-1))
此外,如果需要,您可以使用整列引用。如果这样做,请删除,-1
因为您不必调整标题行。
如果您想使用Power Query
aka Get&Transform
,只需将null替换为No Training Done
然后按照您想要的顺序对结果进行排序即可。这一切都可以从 PQ Editor GUI 中完成,下面是 M 代码
M-代码
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Names", type text}, {"Training", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type",null,"No Training Done",Replacer.ReplaceValue,{"Training"}),
#"Sorted Rows" = Table.Sort(#"Replaced Value",{{"Names", Order.Ascending}})
in
#"Sorted Rows"
推荐阅读
- javascript - 如何使用 JavaScript 更新选定的选项值
- java - 部署 Angular 5 springboot 多模块项目 -jar
- java - JSP - 实例化 servlet 类时出错
- css - z-index 似乎不起作用
- git - 将 pushurl 添加到 git 子模块
- javascript - 为什么示例中的 d3 bar chard 无法在浏览器中显示?
- c# - 如何在多线程应用程序中持续检查互联网连接?
- javascript - 在聚合 mongoose 中使用 $populate
- python - 在字典的典型键中添加新值
- javascript - React 将数据属性传递给 DOM