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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
rpablo
New Member

Help splitting/extracting column by character transition based on condition from another column

Hi all,

 

I need your guidance on how to split/extract a column by character transition if a condition is true.

 

I have a table with two columns:

HostnameUsername
Machine01Username01
Machine02Username02
Cloud Machinev12345
Cloud Machinev67890
Machine03Username03
Cloud Machinev91735

 

My condition must be: IF [Hostname] = "Cloud Machine" THEN split username from non-digit to digit ELSE [Username]
Therefore, my new column must be:

 

HostnameNew Username
Machine01Username01
Machine02Username02
Cloud Machine12345
Cloud Machine67890
Machine03Username03
Cloud Machine91735

 

Any ideas on how to do this either in DAX or PowerQuery?

1 ACCEPTED SOLUTION
DOLEARY85
Resident Rockstar
Resident Rockstar

Hi,

 

try this in a new column in power query:

 

if [Hostname] = "Cloud Machine" then Text.Remove(
[Username],
{
Character.FromNumber(32)..Character.FromNumber(47),
Character.FromNumber(58)..Character.FromNumber(255)
}
)
else [Username]

 

DOLEARY85_0-1687378495477.png

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

View solution in original post

3 REPLIES 3
DOLEARY85
Resident Rockstar
Resident Rockstar

Hi,

 

try this in a new column in power query:

 

if [Hostname] = "Cloud Machine" then Text.Remove(
[Username],
{
Character.FromNumber(32)..Character.FromNumber(47),
Character.FromNumber(58)..Character.FromNumber(255)
}
)
else [Username]

 

DOLEARY85_0-1687378495477.png

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Hi  @DOLEARY85 ,

 

Thank you very much for your help. That worked just as expected.

No problem, happy to help 🙂

Helpful resources

Announcements
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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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