Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Within M Language change "Last, First" Name to "First Last"?

Hi all,

 

Thank you to everyone for this continued support on this community.  It has been incredibly helpful with getting through this project.  So continuing that path...

 

I have code that looks as follows:

 

DetailColumns = Table.ExpandRecordColumn(RecordsOfPage, "PageData", {"FullName", "Field1","Field2","Field3"}​ 

 

[FullName] returns Last, First name (i.e. "Smith, Joe").  I need to transform this to "Joe Smith".

 

I suspect it has something to do with the function: Text.BeforeDelimiter([FullName], ",", 0), type text) and Text.AfterDelimiter([FullName], ",", 0), type text) <--NOTE: SYNTAX MAY/MAY NOT BE CORRECT

 

However, I'm not familiar enough with the M language to how exactly embed this within the ExpandRecordColumn line of code.  I tried to do it afterwards by pulling [FullName] twice, but I can't pull the same field twice.  Advice going either direction would be much appreciated.

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Try this code on add a new column for Power Query:

 

Text.Combine(List.Reverse(Text.Split([Column1],",")), " ")

 

Capture.PNG

 

Did I answer your question? Mark my post as a solution!
Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

6 REPLIES 6
HotChilli
Super User
Super User

Start a new thread and please provide a data sample in text format

camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Try this code on add a new column for Power Query:

 

Text.Combine(List.Reverse(Text.Split([Column1],",")), " ")

 

Capture.PNG

 

Did I answer your question? Mark my post as a solution!
Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Anonymous
Not applicable

Hello! I know this is old but this is what I'm looking for. However I keep getting errors because some of my values are null. How could you edit this query to account for nulls?

Anonymous
Not applicable

@camargos88  Brilliant!!!  Thank you!

 

And thank you to everyone here for suggestions and feedback.

HotChilli
Super User
Super User

Try using 'Add Column from examples' to see what powerbi comes up with.  Give it some good examples .

Anonymous
Not applicable

sweet. thank you! it gave me this: let splitConsultant = Splitter.SplitTextByDelimiter(", ", QuoteStyle.None)([Consultant]) in Text.Combine({splitConsultant{1}?, " ", splitConsultant{0}?}) 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors