0

I am trying to combine 2 columns into one and then replace "Null" rows with the value in an adjacent columns using Excel Power Query. SO far I haven't been able to resolve this issue. These are my unsuccessful attempts:

Attempt 1:

= Table.ExpandTableColumn(Source, "F 52 AGR_1016", {"AGR_NAME"}, {"F 52 AGR_1016.AGR_NAME"}),
 else Table.ReplaceValue(Source, each "", Replacer.ReplaceValue{"New value of line"})

Attempt 2:

= Table.ExpandTableColumn(Source, "F 52 AGR_1016", {"AGR_NAME"}, {"F 52 AGR_1016.AGR_NAME"}), 
if #"F 52 AGR_1016" = "" then Replacer.ReplaceValue("","",{"New Value of line"}), else

I get the following error message, however Excel does not show me where exactly that error is:

Expression.SyntaxError: Token Eof expected.

1 Answer 1

1

It is a bit hard to tell what you are doing, and the code format is incorrect. You can't append if then to Table.ExpandTableColumn

To merge two column: click select them, right click, then choose merge columns

To add a column that tests other column values, add column .. custom column ... and use = if xxx then yyy else zzz

= if [Col1] = null then [Col2] else [Col3]

This code expands three columns; merges the text value of Column1 and Column2 into a new column called Merged; creates Column4 where the result is Merge if Column3 is a null, and Column3 if Column3 is not a null

...
#"Expanded" = Table.ExpandTableColumn(Source, "AllRows", {"Column1", "Column2", "Column3"}, {"Column1", "Column2", "Column3"}),
#"Merged Columns" = Table.CombineColumns(#"Expanded",{"Column2", "Column1"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"),
#"Added Custom" = Table.AddColumn(#"Merged Columns", "Custom4", each if [Column3]=null then [Merged] else [Column3])
Sign up to request clarification or add additional context in comments.

1 Comment

Hey, thanks for your response! Using your code I ended up using a simple if then statement.What I was trying to do is in order to keep the number of columns low is to merge 2 columns and then fill out the remaining blanks. Now I have 2 columns for that, but since it works I'll leave it like that.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.