Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Custom Column filled with a specific value from another column

Hi Power Bi experts,    I am a bit desperate to find a solution and I've been searching in this community with no success So really hope someone can help me with this🙏    I need to add a custom ...
  • jennratten's avatar
    4 years ago

    Hello - this is a way you can do it. 

    Script

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtJRUorVQdCm+kZm+kYGRkYwAef8nPwiICc4syoVLJCUU5oK5PuCOUWpKXB2eUZmCUjGRyk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
        TargetColumnName = "Column1",
        TargetRow = 2, // row indices begin at 0
        // Alternative way to reference the target cell...
        // TargetValue = Source[Column1]{2} 
        TargetValue = Table.Column(Source, TargetColumnName){TargetRow},
        RemoveTopNRows = Table.Skip(Source,TargetRow+1),
        NewColumn = Table.AddColumn(RemoveTopNRows, "New Column", each TargetValue)
    in
        NewColumn

     

    Before

    After