Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Dear all,
I have the data below:
I want to replace the value null in column Week 1-2-3-4 with Median Column for each row --> it's mean for row 5, null value in Week 2 will be replaced to 8 (based on Median Column value in row 5 is 8 )
Thanks
Solved! Go to Solution.
Hello, @neonguyen1803 if your table has nulls only in columns Week 1..4 then
let
Source = your_table,
lst = Table.FromList(
Table.ToList(
Source, (x) => List.ReplaceValue(x, null, List.Last(x), Replacer.ReplaceValue)
), (x) => x, Table.ColumnNames(Source)
)
in
lst
You can do this using the Table.ReplaceValue function with appropriate arguments to look at the Median column for the replacement value.
If your values might include decimals, be sure to set the data types to number rather than Int64.Type.
#"Replace Columns" = List.Select(Table.ColumnNames(#"Previous Step"), each Text.StartsWith(_,"Week")),
#"Replace Nulls with Median" = Table.ReplaceValue(#"Previous Step",
null,
each [Median],
Replacer.ReplaceValue,
#"Replace Columns"),
#"Reset Data Types" = Table.TransformColumnTypes(#"Replace Nulls with Median", List.Transform(#"Replace Columns", each {_, type number}))
in
#"Reset Data Types"
You can do this using the Table.ReplaceValue function with appropriate arguments to look at the Median column for the replacement value.
If your values might include decimals, be sure to set the data types to number rather than Int64.Type.
#"Replace Columns" = List.Select(Table.ColumnNames(#"Previous Step"), each Text.StartsWith(_,"Week")),
#"Replace Nulls with Median" = Table.ReplaceValue(#"Previous Step",
null,
each [Median],
Replacer.ReplaceValue,
#"Replace Columns"),
#"Reset Data Types" = Table.TransformColumnTypes(#"Replace Nulls with Median", List.Transform(#"Replace Columns", each {_, type number}))
in
#"Reset Data Types"
Hello, @neonguyen1803 if your table has nulls only in columns Week 1..4 then
let
Source = your_table,
lst = Table.FromList(
Table.ToList(
Source, (x) => List.ReplaceValue(x, null, List.Last(x), Replacer.ReplaceValue)
), (x) => x, Table.ColumnNames(Source)
)
in
lst
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 7 | |
| 4 | |
| 3 |