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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

PowerQuery - Extract Data if contain

Hi, I am working on PowerQuery.

May I ask how I could extract the data from ( ) only if there is a ( )

ExampleDesired result
TomTom
1(Peter)Peter
DavidDavid
OscarOscar
2(Alex)Alex

Many thanks!

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

Please try the following methods. Use Split Column twice in Power query. first split with "(" and second split with ")".

vzhangti_0-1657021115365.pngvzhangti_1-1657021132742.pngThe results are shown in the figure.

vzhangti_2-1657021180083.png

Then add a custom column.

if[Example.2.1]<>null then [Example.2.1] else [Example.1]

vzhangti_3-1657021273493.png

You will get the results you expect.

vzhangti_4-1657021291774.png

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

Please try the following methods. Use Split Column twice in Power query. first split with "(" and second split with ")".

vzhangti_0-1657021115365.pngvzhangti_1-1657021132742.pngThe results are shown in the figure.

vzhangti_2-1657021180083.png

Then add a custom column.

if[Example.2.1]<>null then [Example.2.1] else [Example.1]

vzhangti_3-1657021273493.png

You will get the results you expect.

vzhangti_4-1657021291774.png

 

Best Regards,

Community Support Team _Charlotte

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

otravers
Community Champion
Community Champion

Try the "column from example" feature, it's pretty good at figuring things out:

https://docs.microsoft.com/en-us/power-query/column-from-example

------------------------------------------------
1. How to get your question answered quickly - good questions get good answers!
2. Learning how to fish > being spoon-fed without active thinking.
3. Please accept as a solution posts that resolve your questions.
------------------------------------------------
BI Blog: Datamarts | RLS/OLS | Dev Tools | Languages | Aggregations | XMLA/APIs | Field Parameters | Custom Visuals

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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