PowerQuery - Replace values in Dynamic Columns

42 Views Asked by At

I have a table as below. Only the first column "Ticket No" is constant. For the other columns, depending on the data source i can have multiple columns of a similar nature as the screenshot below (in the screenshot there are only 2 columns but there can be more such columns depending on data source)

What i need is for each dynamic column that appears based on the data source apart from the 1st column, to check if the value in each row is having a value or if its null. If it is having a value, then to replace with 1. If its null then to replace with 0

Current Table

Current Table

Expected Outcome

enter image description here

1

There are 1 best solutions below

2
horseyride On BEST ANSWER

You can try this in powerquery to apply a transform to each column except the first

let  Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Columns = List.RemoveFirstN(Table.ColumnNames(Source),1),
Transform = List.Transform(Columns, (x)=>{x, each if _=null then 0 else 1, type number}),
#"Fix" = Table.TransformColumns(Source, Transform)
in #"Fix"

enter image description here