Forum Discussion
Multiple Add column
- Anonymous5 years ago
ok.
Then you have to generate/construct the somethinkID list.
You can create manually a list:
lstID={productid,statusid,responseid} or select in somw way from column names list
lstID= List.Select(Table.ColumnNames(tbl), each Text.EndsWith(_,"id"))
Then you have to generate/construct in similar way a labelList.
lstLabel={l1,l2,l3}
Finally you could use list accumulate in the way I showed you.
ASs I don't know the value.metadata function
and MS explanation is very succint
I try to understand the way you used it.
You should use, i think, in this way inside Table.addcolumn funcion:
List.accumulate({0..2},tbl, (s,c)=>List.AddColumn(s, listLabel{c}, each value.metadata(table.Column(s, lstID{c})) )
check the sintax and try.
I don't have time now to go more in depth
- 5 years ago
Hi, Gugan_BI
As is suggested by Gugan_BI , you may use 'Table.AddColumn' function within 'List.Accumulate' function. I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
Then you may add a new step with the following m codes.
= let names = Table.ColumnNames(#"Changed Type"), list = List.Select(names,each Text.EndsWith(_,"id")), re = List.Accumulate( list, #"Changed Type", (s,c)=>Table.AddColumn(s,c&"_label",each Value.Metadata( Table.Column(#"Changed Type",c) )[OData.Community.Display.V1.FormattedValue]?) ) in reResult:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for response.
Given below more details. Fundid, statusid and response id are id values (some system generate id from Dynamics)
using below query will give the label/description of each id column.
value.metadata([statusid])[OData.Community.Display.V1.FormattedValue]?
created 3 new columns to get actual description of id values. Product_lablel, Status_label and response_label are new column that contains the description of id values.
so trying to see if i can combine the below three steps into minimal steps. I may have more such id columns.
#"add custom" =Table.addcolumn(table1,"product_label", each value.metadata([productid])[OData.Community.Display.V1.FormattedValue]?)
#"add custom1" =Table.addcolumn(#"add custom","Status_label", each value.metadata([statusid])[OData.Community.Display.V1.FormattedValue]?)
#"add custom2" =Table.addcolumn(#"add custom1","response_label", each value.metadata([responseid])[OData.Community.Display.V1.FormattedValue]?)
ok.
Then you have to generate/construct the somethinkID list.
You can create manually a list:
lstID={productid,statusid,responseid} or select in somw way from column names list
lstID= List.Select(Table.ColumnNames(tbl), each Text.EndsWith(_,"id"))
Then you have to generate/construct in similar way a labelList.
lstLabel={l1,l2,l3}
Finally you could use list accumulate in the way I showed you.
ASs I don't know the value.metadata function
and MS explanation is very succint
I try to understand the way you used it.
You should use, i think, in this way inside Table.addcolumn funcion:
List.accumulate({0..2},tbl, (s,c)=>List.AddColumn(s, listLabel{c}, each value.metadata(table.Column(s, lstID{c})) )
check the sintax and try.
I don't have time now to go more in depth