分组数据时仅获得相关行
我有参考的数据,我希望分组和提取最高和最常见的值,同时保留相关参考文献:
绿色的桌子是我到目前为止所取得的成就:
m代码:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"CAS", type text}, {"Type ", type text}, {"Value ", type text}, {"Ref", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"CAS", "Type "}, {{"Value Most Common", each List.Mode([#"Value "]), type nullable text}, {"Ref", each Text.Combine([Ref], ", "), type nullable text}, {"Value Lowest", each List.Max([#"Value "]), type nullable text}})
in
#"Grouped Rows"
我遇到的问题是如何最好地将参考文献分解为最常见和最低的值。尽管进行了多次尝试,但我只是做对了。问题之所以出现,是因为通过按值分裂列,引用链接了,但是从输入来判断这必须是可能的。我怀疑在分组之前我需要一些额外的步骤。
此外,我不确定如何使用分组来捕获最常见值之间有联系的模式。 list.modes返回列表,但我再次遇到错误。目前,我只返回单个模式。这是一个较少的问题,但与第3行所需的第3行一样,这是一个很好的问题。
Data:
CAS Type Value Ref
77-92-9 NOAEL 1200 WebNet
77-92-9 NOAEL 1200 Wiki
77-92-9 NOAEL 4000 ECHA
77-92-9 DNEL 500 RB Data
25265-71-8 DNEL 51 WebNet
25265-71-8 DNEL 24 ECHA
25265-71-8 DNEL 24 ECHA
25265-71-8 DNEL 50 ECHA
25265-71-8 DNEL 50 ECHA
25265-71-8 DNEL 10 ECHA
25265-71-8 NOAEL 200 OECD
106-24-1 DNEL 13.75 ECHA
106-24-1 DNEL 13.75 ECHA
106-24-1 NOAEL 300 RIFM
106-24-1 NOAEL 550 ECHA
106-24-1 NOAEL 50 SAM
106-24-1 NOAEL 50 RIFM
128-37-0 NOAEL 25 ECHA
128-37-0 NOAEL 25 ECHA
128-37-0 NOAEL 25 SAM
128-37-0 ADI 0.3 MMMD
128-37-0 ADI 0.25 JECFA
128-37-0 ADI 0.25 EFSA
60-12-8 DNEL 5.1 ECHA
60-12-8 NOAEL 385 RIFM
I have data with reference that I wish to group and extract the highest and most common values whilst retaining the relevant references:
The table in green is what I have achieved so far:
M Code:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"CAS", type text}, {"Type ", type text}, {"Value ", type text}, {"Ref", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"CAS", "Type "}, {{"Value Most Common", each List.Mode([#"Value "]), type nullable text}, {"Ref", each Text.Combine([Ref], ", "), type nullable text}, {"Value Lowest", each List.Max([#"Value "]), type nullable text}})
in
#"Grouped Rows"
The problem I am having is how best to separate out the References for The Most common and Lowest values. Despite multiple attempts, I just can't get it right. The problem arises because by Splitting columns by Value the references become linked however judging from the input this must be possible. I suspect I need some additional step before grouping.
Additionally, I am unsure how to use grouping to capture Modes where there is a tie between most common values. List.Modes returns a List but again I a running into errors. Currently, I only return the single mode. This is a lesser issue but would be nice as with 24,50 in row 3 of desired.
Data:
CAS Type Value Ref
77-92-9 NOAEL 1200 WebNet
77-92-9 NOAEL 1200 Wiki
77-92-9 NOAEL 4000 ECHA
77-92-9 DNEL 500 RB Data
25265-71-8 DNEL 51 WebNet
25265-71-8 DNEL 24 ECHA
25265-71-8 DNEL 24 ECHA
25265-71-8 DNEL 50 ECHA
25265-71-8 DNEL 50 ECHA
25265-71-8 DNEL 10 ECHA
25265-71-8 NOAEL 200 OECD
106-24-1 DNEL 13.75 ECHA
106-24-1 DNEL 13.75 ECHA
106-24-1 NOAEL 300 RIFM
106-24-1 NOAEL 550 ECHA
106-24-1 NOAEL 50 SAM
106-24-1 NOAEL 50 RIFM
128-37-0 NOAEL 25 ECHA
128-37-0 NOAEL 25 ECHA
128-37-0 NOAEL 25 SAM
128-37-0 ADI 0.3 MMMD
128-37-0 ADI 0.25 JECFA
128-37-0 ADI 0.25 EFSA
60-12-8 DNEL 5.1 ECHA
60-12-8 NOAEL 385 RIFM
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这一切都在分组中:
编辑为多种模式,如您的编辑
数据更改为具有多种模式的Demo多refs的数据

It's all in the grouping:
Edited to account for multiple modes as seen after your edit
Data changed to demo multiple Refs with Multiple Mode
