Forum Discussion

KyleFurner's avatar
KyleFurner
Frequent Visitor
5 years ago
Solved

Combine rows and replace null values

Hi all,   I have a table which holds monthly reporting data for a number of different projects. Each project takes up a single row.  Within the table there are a number of columns for different st...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi KyleFurner 

     

    If I understand it correctly, you want to extract the first two values for the 3 columns then split to two as last month and this month, so you can add a custom column to do it, I did only for OverallStatus, you can paste it in Advanced Editor to see it

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQoJCnUFUgFF+VmpySWOEGZ6UWIuSDIgI7E4FcQwMjACUcH5pUXJqQogVcaG+gbG+lDxoNQU68jUnJz8cmsCPGtCRKxOtJIRhrucsLjLiDh3gbCzv6+vq1+IY1CkQohrRAheGahboRSmPBYEcrMxhpudyQ9Layw0NntjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [RowNumber = _t, #"Director Approved" = _t, Project = _t, Program = _t, #"Project phase" = _t, #"Target phase completion date" = _t, #"Funding source" = _t, #"Reporting Cycle Date" = _t, OverallStatus1 = _t, CostStatus2 = _t, TimeStatus3 = _t, ResourceStatus4 = _t, ScopeStatus5 = _t, StakeholderStatus6 = _t, GovStatus7 = _t, BenefitsStatus8 = _t, QualityStatus9 = _t, #"Monthly Summary" = _t]),
        #"Removed Other Columns" = Table.SelectColumns(Source,{"RowNumber", "Program", "Project", "Project phase", "Target phase completion date", "Funding source","Reporting Cycle Date","OverallStatus1", "CostStatus2", "TimeStatus3"}),
        #"Added Custom" = Table.AddColumn(#"Removed Other Columns", "Overall Status last month", each List.FirstN( Text.Split([OverallStatus1],";"),2){0}),
        #"Added Custom1" = Table.AddColumn(#"Added Custom", "Overall Status this month", each List.FirstN( Text.Split([OverallStatus1],";"),2){1})
    in
        #"Added Custom1"