The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Dear friend,
How to use the if loop to add a new column like this info.
I want a new column looking for other columns but in the row is not null if null will look for a higher row looping like below but i don't want write long till -60
if [Column5]<> null
then [Column5]
else if #"Replaced Value" [Column5]{[Index]-1} <> null
then #"Replaced Value" [Column5]{[Index]-1}
else if #"Replaced Value" [Column5]{[Index]-2} <> null
then #"Replaced Value" [Column5]{[Index]-2}
else if #"Replaced Value" [Column5]{[Index]-3} <> null
then #"Replaced Value" [Column5]{[Index]-3}
Thank you
@Anonymous , You can use List.Select or each
new column example
let
_ind = [Index]
_Table = Table.Select(#"Replaced Value" , each [Index] <_ind)
_list = List.Select(#"Replaced Value"[Column5] , each _ <> null)
_value = if List.IsEmpty(_list) then _list{0} else null
in
_value
List.Reverse can be used in case the it in revrese order