Last active
July 24, 2025 05:52
-
-
Save bjulius/e25412c0cd3e83857ff5c45052df5a83 to your computer and use it in GitHub Desktop.
Dynamic M Function to Replace Blanks with Nulls ( #DataCleaning, #MCode, #M, #PowerQuery )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
ReplaceBlanksWithNulls = (inputTable as table) as table => | |
let | |
columnNames = Table.ColumnNames(inputTable), | |
replaceBlanksInColumn = (table, columnName) => Table.ReplaceValue(table, "", null, Replacer.ReplaceValue, {columnName}), | |
transformedTable = List.Accumulate(columnNames, inputTable, (state, current) => replaceBlanksInColumn(state, current)) | |
in | |
transformedTable | |
in | |
ReplaceBlanksWithNulls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had a weird issue where NULL was stored as a string in some data I received, this would be a good solution for that too. Thanks for sharing! Darrell