Forum Discussion
Add Custom Row (Table.InsertRow)
- 8 years ago
InsertRows will do what you want.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIE4sjUYqVYnWglIyDbCcaPBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Dimension = _t, #"Dimension Name" = _t, #"From Data Source" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Dimension", Int64.Type}}), Custom1 = Table.InsertRows(#"Changed Type",2, { [Dimension = 3, Dimension Name = "Custom Row", From Data Source = "No"] }) in Custom1 - 8 years ago
InsertRows will do what you want.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIE4sjUYqVYnWglIyDbCcaPBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Dimension = _t, #"Dimension Name" = _t, #"From Data Source" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Dimension", Int64.Type}}), Custom1 = Table.InsertRows(#"Changed Type",2, { [Dimension = 3, Dimension Name = "Custom Row", From Data Source = "No"] }) in Custom1
InsertRows will do what you want.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIE4sjUYqVYnWglIyDbCcaPBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Dimension = _t, #"Dimension Name" = _t, #"From Data Source" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Dimension", Int64.Type}}),
Custom1 = Table.InsertRows(#"Changed Type",2, { [Dimension = 3, Dimension Name = "Custom Row", From Data Source = "No"] })
in
Custom1- LiChauki8 years agoRegular Visitor
Hi
Is it possible to add a row based on certain conditions?
The logic for my query is:
Current table
Product number Province
A001 Ontario
A001 Alberta
B001 Quebec
B001 Alberta
For each product number in the table IF (Province) <> "Yukon Territory" then INSERT row "Product number and Province = "Yukon Territory"
IF (Province) <> "Quebec" then INSERT row "Product number and Province = "Quebec"
Desired output
Product number Province
A001 Ontario
A001 Alberta
A001 Yukon Territory
A001 Quebec
B001 Quebec
B001 Alberta
B001 Yukon Territory
- puraskar_award5 years agoFrequent Visitor
Any luck on this? I know we need to change the "Dimension = 3" to a dynamic number that is equal to total columns in the table as one year may have 2 columns but later may have 3 or more as in finance you expect your business needs to grow. Adding a condition prior to that step to validate the content value of the column is what we need to do. Hopefully someone can suggest what function could accomplish these two things to modify code below.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIE4sjUYqVYnWglIyDbCcaPBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Dimension = _t, #"Dimension Name" = _t, #"From Data Source" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Dimension", Int64.Type}}), Custom1 = Table.InsertRows(#"Changed Type",2, { [Dimension = 3, Dimension Name = "Custom Row", From Data Source = "No"] }) in Custom1
- Anonymous7 years agoNot applicable
Works great! Thanks