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

Putting last string element from a column into a new column

Hello, 

I woud like to create a new column in Power BI desktop that it based on another column in my data. 

The new column should only take the last string element of the previous column. For example:

If one row in the column contains: ['Elsa', 'William', 'Kate'], the new column should only contain: ['Kate'] in the corresponding row.

All rows don't have the same amount of string elements (i.e. some have 4 names and some none at all). 

 

I would be very grateful if anyone could help me solve this, 

Thank you, 

Louise 

 

 

2 ACCEPTED SOLUTIONS
mahoneypat
Employee
Employee

Not sure if you string actually includes the [ and ' symbols, but you can use this formula in a custom column.  If you do need those characters, you can concatenate them to the result (or use Replace Values to remove them before or after this step).

 

= List.Last(Text.Split([ListColumn], ", "))

 

mahoneypat_0-1627915344075.png

 

Pat

 

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try using the extract function in the query editor.

Vlianlmsft_1-1628044888282.png

 

Vlianlmsft_0-1628044837485.png

 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try using the extract function in the query editor.

Vlianlmsft_1-1628044888282.png

 

Vlianlmsft_0-1628044837485.png

 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mahoneypat
Employee
Employee

Not sure if you string actually includes the [ and ' symbols, but you can use this formula in a custom column.  If you do need those characters, you can concatenate them to the result (or use Replace Values to remove them before or after this step).

 

= List.Last(Text.Split([ListColumn], ", "))

 

mahoneypat_0-1627915344075.png

 

Pat

 

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Thank you for your response ! 

The brackets and quotation marks are indeed part of the column (my data is an imported csv). 

Could you please show me where I should enter this line of code ? I have tried to add it when creating a new column (I go to Modeling then to New Column) but it doesn't seem to be DAX syntax. 

 

Thank you, 

Louise

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.