Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hallo all,
I need to refer to and then use the column name in an IF statement.
For example, in a new column, called Category, I want to say:
if any of columns start with 100. and the value within the columns also begins with 100. then "Sales Cat A" else if any of the columns start with 200. and the value within the columns also begins with 200. then "Sales Cat B" else if....
I know how to construct the IF statement itself, but I need help please with referring to the columns names/headers within the formula.
Is this possible?
Cheers.
Solved! Go to Solution.
NewStep=Table.AddColumn(PreviousStepName,"Category",each List.Skip({{"100.","Sales Cat A"},{"200.","Sales Cat B"},{"300.","Sales Cat C"}},(x)=>Table.IsEmpty(Table.SelectRows(Record.ToTable(_),each Text.StartsWith([Name],x{0}) and Text.StartsWith([Value],x{0})))){0}?{1}? ??"Other Cat")
NewStep=Table.AddColumn(PreviousStepName,"Category",each List.Skip({{"100.","Sales Cat A"},{"200.","Sales Cat B"},{"300.","Sales Cat C"}},(x)=>Table.IsEmpty(Table.SelectRows(Record.ToTable(_),each Text.StartsWith([Name],x{0}) and Text.StartsWith([Value],x{0})))){0}?{1}? ??"Other Cat")
Absolute magic...worked perfectly....thanks Daniel!