供参考...
- let
- 源 = Excel.CurrentWorkbook(){[Name="表1"]}[Content],
- grp = Table.Group(源,"Material",{"g",Table.ToRecords},1),
- rcd = Record.FromList(grp[g],grp[Material]),
- fnx = (x,y,z)=> if not Record.HasFields(rcd,x) then y else
- List.TransformMany( Record.Field(rcd,x),
- each [ num = [Component quantity]*z,
- red = _&[QTY=num],
- rec = (if Record.HasFields(rcd,[Component]) then
- {red} else {}) & @fnx([Component],{red},num)
- ] [rec],
- (p,q)=>q ),
- top = List.Difference(List.Distinct(源[Material]),源[Component]),
- rsl = Table.FromRecords(
- List.TransformMany( top,
- each fnx(_,{},1),
- (x,y)=>[Top=x]&y ) )
- in
- rsl
复制代码
|