Forum Discussion
Rowwise Dynamic Average of values
- 3 years ago
Hi,
this solution would work if there are only numbers provided in the columns. As Onkar already mentioned there will be some blank or null values. These values would cause an error, because they cannot be transformed into numbers automatically.
I suggest adding a new column with a custom method using the advanced editor:
Table.AddColumn( <Previous_Step>, "Average", each List.Average( List.Select( Record.ToList( Record.SelectFields(_, {"Value 1", "Value 2", "Value 3", "Value 4"}) ), each Value.Is(Value.FromText(_), type number) ) ) )Please note that you have to replace the placeholder „<Previous_Step>“ with the name of the previous step of your power query script.
Hi,
this solution would work if there are only numbers provided in the columns. As Onkar already mentioned there will be some blank or null values. These values would cause an error, because they cannot be transformed into numbers automatically.
I suggest adding a new column with a custom method using the advanced editor:
Table.AddColumn(
<Previous_Step>,
"Average",
each List.Average(
List.Select(
Record.ToList(
Record.SelectFields(_, {"Value 1", "Value 2", "Value 3", "Value 4"})
),
each Value.Is(Value.FromText(_), type number)
)
)
)Please note that you have to replace the placeholder „<Previous_Step>“ with the name of the previous step of your power query script.
Sum does not consider null values when adding, in either case it would be easier to replace the nulls/blanks with a 0 and the result would be the same.