如何返回一组匹配的行并连接其中一列?
我想要做这样的事情:
=related(othertable[aColumn])
但是,如果有多个匹配的行,它应该连接所有匹配的aColumn
值。
像这样的东西,但工作:
=concatenate(values(filter(othertable,othertable[bColumn]=[value in this table])))
我不知道如何在DAX中做到这一点,所以在Power Query中做了。
//using this as a start: aTable = #table({"A","B","C"},{{1,"a",1},{1,"b",2},{2,"c",3},{3,"d",4}}), //I'm concatenating text...so need to have a function stating what to concatenate with fCombine = Combiner.CombineTextByDelimiter(":"), aGroupRowsCat = Table.Group( aTable, {"A"}, {{"CatOfB", each fCombine([C]), type text}} )
我结束了:
A|CatOfB -+------ 1|a:b 2|c 3|d
Jason Thomas 在PowerPivot的博客postGroup Multiple Rows to Single Delimited Row中回答了这个问题
在那篇文章中,他解释说,如果你首先创build一个父/子层次,那么你可以使用PATH
来返回一个逗号分隔的列表。
他使用RANKX
函数和一点逻辑创build父/子关系,然后计算感兴趣列的父值,最后使用PATH
函数计算逗号分隔列表。