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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
LMSReportsHelp
Frequent Visitor

Replacing using wildcard

I have been reading posts on here and trying to recreate solutions, but none of them are working and I have no idea why.  I have a list of information which I want to use "Transform Data" to extract the unique information into a new column and then convert into a standard format to show more easily in a table/report.

 

The data looks something like this:

CLST_A1 Leadership Summit
CLST_A2 Leadership Summit
CLST_A3 Leadership Summit
CLST_B1 Leadership Summit

 

We currently have items through "F" with schedules through "S".  I already have a new column to extract the group (A1/A2/A3/etc), but now I am trying to replace the A1/A2/A3 to just be "101" since that's the series. In the report, that is what I need to summarize by.  So I would like to be able to create a simple replacement of "CLST_[wildcard/*/%/?]1 Leadership Summit = CLST_101 Leadership Summit" - rather than 60+ and having to edit every time a new group is identified/added. 

 

Please explain to me like the DAX/Power BI newbie I am how to make this work.

1 ACCEPTED SOLUTION
Sahir_Maharaj
Super User
Super User

Hello @LMSReportsHelp,

 

Can you please try creating this calculated column:

Transformed Column = 
VAR OriginalText = YourTable[ColumnName]
VAR Prefix = LEFT(OriginalText, 5)
VAR SuffixIndex = SEARCH(" Leadership Summit", OriginalText, 1, LEN(OriginalText))
VAR Suffix = MID(OriginalText, SuffixIndex, LEN(OriginalText) - SuffixIndex + 1)
VAR GroupCode = MID(OriginalText, 6, SuffixIndex - 6) -- Extract the group part like A1, A2, B1, etc.
VAR NewGroupCode = IF(RIGHT(GroupCode, 1) = "1", "101", GroupCode)
RETURN 
Prefix & NewGroupCode & Suffix

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

2 REPLIES 2
Sahir_Maharaj
Super User
Super User

Hello @LMSReportsHelp,

 

Can you please try creating this calculated column:

Transformed Column = 
VAR OriginalText = YourTable[ColumnName]
VAR Prefix = LEFT(OriginalText, 5)
VAR SuffixIndex = SEARCH(" Leadership Summit", OriginalText, 1, LEN(OriginalText))
VAR Suffix = MID(OriginalText, SuffixIndex, LEN(OriginalText) - SuffixIndex + 1)
VAR GroupCode = MID(OriginalText, 6, SuffixIndex - 6) -- Extract the group part like A1, A2, B1, etc.
VAR NewGroupCode = IF(RIGHT(GroupCode, 1) = "1", "101", GroupCode)
RETURN 
Prefix & NewGroupCode & Suffix

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Why do you create a variable of the original column instead of just referencing that column in the other variables?

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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