Forum Discussion
Dmitry_Chukov
9 years agoFrequent Visitor
How to insert different values in different rows in one column
Have a table with four columns (each column have about 100 rows), and i need to add a new column which have a futher structe: 1. Form the 1 to 4 row value "Name_1" 2. Form the 5 to 9 row value ...
- 9 years ago
Steps:
- Add a standard 0-based Index column.
- Transform - Standard - Modulo 5.
- Add a new (temporary) column "Custom" (see code below).
- Fill Down [Custom].
- Add the NewColumn with null if Index = 0, otherwise the value from [Custom]
Added to the previous code:
#"Added Index2" = Table.AddIndexColumn(#"Calculated Modulo", "Index", 0, 1), #"Calculated Modulo1" = Table.TransformColumns(#"Added Index2", {{"Index", each Number.Mod(_, 5), type number}}), #"Added Custom" = Table.AddColumn(#"Calculated Modulo1", "Custom", each if [Index] = 0 then [Data] else null), #"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"}), #"Added Custom1" = Table.AddColumn(#"Filled Down", "NewColumn", each if [Index] = 0 then null else [Custom]), #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Index", "Custom"})
MarcelBeug
9 years agoCommunity Champion
Steps:
- Add a standard 0-based Index column.
- Transform - Standard - Modulo 5.
- Add a new (temporary) column "Custom" (see code below).
- Fill Down [Custom].
- Add the NewColumn with null if Index = 0, otherwise the value from [Custom]
Added to the previous code:
#"Added Index2" = Table.AddIndexColumn(#"Calculated Modulo", "Index", 0, 1),
#"Calculated Modulo1" = Table.TransformColumns(#"Added Index2", {{"Index", each Number.Mod(_, 5), type number}}),
#"Added Custom" = Table.AddColumn(#"Calculated Modulo1", "Custom", each if [Index] = 0 then [Data] else null),
#"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"}),
#"Added Custom1" = Table.AddColumn(#"Filled Down", "NewColumn", each if [Index] = 0 then null else [Custom]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Index", "Custom"})Dmitry_Chukov
9 years agoFrequent Visitor
I have made everything thanks to you. My report now works, like i was planing. Thank you!