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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
JustSayJoe
Advocate IV
Advocate IV

Need more efficient "containsstring" method

I have a table (Advertising) with these three columns.

  • Campaign
  • Ad Set
  • Ad Name

Each of the columns are text strings that use multiple underscores as delimiters. The number of delimiters is not always the same.

 

Examples of a value for each column:

  • Campaign
    • Facebook_RandomTitle_125
  • Ad Set
    • Interest_Outdoors_125
  • Ad Name
    • Video_Launch_30seconds_Captions_125

 

That underscore 125 (_125) value in the examples above is the value I'm trying identify to create a separate calculated column with just the 125 value. That value is used to join to another table to identify the Owner for filtering purposes in my report.

 

Currently I'm running a way too long DAX formula to build that calculated column, which first looks at the Campaign fields with a CONTAINSSTRING to search for _125 and return the value 125 if found (all wrapped in a SWITCH ( TRUE() statement). It does this for every new Owner I add, so a new row is added to lookup that new number. It then searches all the Ad Sets and Ad Names after that (the order of searching Campaign, Ad Set, and then Ad Name is important for my purposes).

 

As you can imagine this DAX is getting way too large and slow with all the containsstring searches on text fields. Does anybody have a better more efficient solution they could suggest for me to accomplish this?

1 ACCEPTED SOLUTION

then pls provide some sample data and the expected output. 





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

Proud to be a Super User!




View solution in original post

7 REPLIES 7
v-pagayam-msft
Community Support
Community Support

Hi @JustSayJoe ,

Can you please confirm whether you have resolved issue. If yes, you are welcome to share your workaround and mark it as a solution so that other users can benefit as well. This will be helpful for other community members who have similar problems to solve it faster. 

If we don’t hear back, we’ll go ahead and close this thread.Should you need further assistance in the future, we encourage you to reach out via the Microsoft Fabric Community Forum and create a new thread. We’ll be happy to help.

Thank you.

v-pagayam-msft
Community Support
Community Support

Hi @JustSayJoe ,
we haven't heard back from you regarding our last response and wanted to check if your issue has been resolved.
If our response addressed your query, please mark it as Accept Answer and click Yes if you found it helpful.
If you have any further questions, feel free to reach out.
Thank you for being a part of the Microsoft Fabric Community Forum!

v-pagayam-msft
Community Support
Community Support

Hi @JustSayJoe ,
May I ask if you have gotten this issue resolved? If it is solved, please mark the helpful reply or share your answer and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.
Thank you.

Regards,
Pallavi.

Ashish_Excel
Super User
Super User

Hi,

Using Power Query, extract everything after the last delimiter.

ryan_mayu
Super User
Super User

then what about not using containsstring function.

 

extract 125 in the PQ

11.png

 

or use DAX to extract 125

 

Column = mid('Table'[column1],FIND("_",'Table'[column1],1,0)+1,100)
12.png




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

Proud to be a Super User!




Thank you for the response. My problem is, the values in the column do not maintain a standard naming convention, so there's a lot of cleanup after using PQ to split the column at the right most delimiter.

 

I'm thinking I may need to bear down and set aside a bunch of hours to manually clean up a ton of historical data...

then pls provide some sample data and the expected output. 





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

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.