Forum Discussion
VRMENDESadq
1 year agoFrequent Visitor
Return all values appearing in a given column
HI, I need to create a custom column that shows all the values in the "Origem" column according to the value in the "Produto" column, for example: Produto Origem Custom Colunm 1 A A,...
- Anonymous1 year ago
Firstly, I duplicated the Table and named it Table2.
In Table, this is the M-Code to transform the column to the custom column that you want:
= Table.Group(Source, {"Produto"}, {{"Custom Column", each Text.Combine([Origem], ";"), type text}})This is the result:
Then I use merge function in PQ to add custom column to Table2 to get the final result.
- 1 year ago
pls try again
let lst = List.Buffer( Table.ToList( from,(x)=>x)), f= (w)=> Text.Combine( List.Transform(List.PositionOf( List.Transform(lst,(z)=>z{0}),w,Occurrence.All), (x)=> lst{x}{1}?),", "), Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJUitWBsJzALCO4mBGKmDOYZQyXNYbLmkDEYgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Produto = _t, Origem = _t]), from = Table.TransformColumnTypes(Source,{{"Produto", Int64.Type}, {"Origem", type text}}), #"Added Custom1" = Table.AddColumn(from, "Custom", each f([Produto])) in #"Added Custom1"
Greg_Deckler
1 year agoCommunity Champion
VRMENDESadq Try:
Column =
VAR __Produto = [Produto]
VAR __Table = FILTER( 'Table', [Produto] = __Produto )
VAR __Return = CONCATENATEX( __Table, [Origem], "," )
RETURN
__Return
Measure =
VAR __Produto = MAX([Produto])
VAR __Table = FILTER( ALLSELECTED('Table'), [Produto] = __Produto )
VAR __Return = CONCATENATEX( __Table, [Origem], "," )
RETURN
__Return
VRMENDESadq
1 year agoFrequent Visitor
Greg_Deckler this is DAX or M, I try to apply this codes in M and doesn't work, do you can help me?
- Greg_Deckler1 year agoCommunity Champion
VRMENDESadq Sorry, that was DAX. Wasn't paying attention.