Forum Discussion
Creating a custom column in Power BI for lowest level in a hierarchy
- 6 years ago
Sure: Just add a column with this formula:
List.Last(List.Select(Record.FieldValues(_), each _ <> null))It selects the last value from the row's values that is not null.
- 6 years ago
Sure: You select the fields first that shall be considered:
List.Last(List.Select(Record.FieldValues(Record.SelectFields(_, {ListOfColumnNames})), each _ <> null))... unfortunately the latest code editor doesn't allow any custom code highlighting any more, but the addition is happening on the innermost level of the formula: Record.SelectFields(_, {ListOfColumnNames})
Actually, is there a way to refine the custom column a bit more to select the last from amongst certain columns? I just noticed that upon adding additional columns, it would confuse things and start pulling the last column added instead of from the original hierarchy.
Sure: You select the fields first that shall be considered:
List.Last(List.Select(Record.FieldValues(Record.SelectFields(_, {ListOfColumnNames})), each _ <> null))
... unfortunately the latest code editor doesn't allow any custom code highlighting any more, but the addition is happening on the innermost level of the formula: Record.SelectFields(_, {ListOfColumnNames})