The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi all,
I'm stuck on this and need some help writing an M statement..
I have 3 columns - FirstName, MiddleName, LastName. FirstName and LastName are 100% populated. Some people don't have MiddleNames - leaving it blank
I've tried writing a statement to concatenate all 3 columns with a space - but the statement only works when all three columns are populated.
How can I write a statement that says if MiddleName is blank, then concatenate FirstName and LastName, otherwise concatenate FirstName, MiddleName, and LastName?
here is what i tried: =
Table.AddColumn(#"Filtered Rows1", "FirstNameLastName", each [FirstName] & if [MiddleName] <> null and [MiddleName] <> "" then " " & [MiddleName] & ". " else " " & [LastName])
Solved! Go to Solution.
@murphm6 You could do this:
#"Added Custom" = Table.AddColumn(#"Changed Type", "Middle", each if [MiddleName] <> null and [MiddleName] <> "" then [MiddleName] & ". " else null),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom", each [FirstName] & " " & [Middle] & [LastName])
@murphm6 You could do this:
#"Added Custom" = Table.AddColumn(#"Changed Type", "Middle", each if [MiddleName] <> null and [MiddleName] <> "" then [MiddleName] & ". " else null),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom", each [FirstName] & " " & [Middle] & [LastName])