Hi All,
i'm new to the M Query language and looking for some help please. I'm looking to replace text in a given column given a set of conditions in the other columns. Please see below the M query in the advance editor and in particular the bold text. Here I've created a new entry that would appear in the query applied steps window in the power query editor that I have called "Replace Values". The logic is if Data.Column4 column equals "London" then replace null values in Data.Column5 with London. However when I save the query below I get the error
Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?
I plan to change the expression to test for multiple conditions however I need to get the basic expression working first :-)
The other frustration i had with the "if" statement is it had to have an else even though I didn't require it, am i doing something wrong here?
Thank you for your time
John
let
FullFilePath = "C:\PermanentDwellings.xlsx",
Source = Excel.Workbook(File.Contents(FullFilePath)),
#"Expanded Data" = Table.ExpandTableColumn(Source, "Data", {"Column1", "Column10", "Column11", "Column12", "Column13", "Column14", "Column15", "Column16",
"Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9"}, {"Data.Column1", "Data.Column10", "Data.Column11", "Data.Column12",
"Data.Column13", "Data.Column14", "Data.Column15", "Data.Column16", "Data.Column2", "Data.Column3", "Data.Column4", "Data.Column5", "Data.Column6", "Data.Column7",
"Data.Column8", "Data.Column9"}),
#"Filled Down" = Table.FillDown(#"Expanded Data",{"Data.Column4"}),
#"Removed Blank Rows" = Table.SelectRows(#"Filled Down", each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null}))),
#"Filtered Rows" = Table.SelectRows(#"Removed Blank Rows", each ([Name] = "1998-99" or [Name] = "1999-00" or [Name] = "2000-01" or [Name] = "2001-02" or [Name] = "2002-03" or
[Name] = "2003-04" or [Name] = "2004-05" or [Name] = "2005-06" or [Name] = "2006-07" or [Name] = "2007-08" or [Name] = "2008-09" or [Name] = "2009-10" or [Name] = "2010-11" or
[Name] = "2011-12" or [Name] = "2012-13" or [Name] = "2013-14" or [Name] = "2014-15")),
#"Replace Values" = if [Data.Column4] = "London" then Table.ReplaceValue(#"Filtered Rows", "null", "London", Text.Replace, {[Data.Column5]}) else Table.ReplaceValue(#"Filtered Rows",
"null", "null", Text.Replace, {[Data.Column5]})
in
#"Replace Values"
- Edited by Shiangoli Thursday, July 16, 2015 2:31 PM