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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Jenny_Sommet
New Member

DAX formula to extract text before and after special character

Hello!

 

I am new to the community and hoping for some help! In the column below, I only want to extract the text that comes after '- ' and before ' -' for the entire column of values. Please can you help with DAX calculation? I am unable to use PowerQuery for various reasons.

 

EDPC - 2023.Q1 - DP (want to extract 2023.Q1)

LRM - 2023.1 - UG - DP (want to extract 2023.1)

LRCM - 2022.2 - PG - DP (want to extract 2022.2)

 

Thank you for your help!

2 ACCEPTED SOLUTIONS
tamerj1
Super User
Super User

Hi @Jenny_Sommet

Please try

Column2 =
VAR String = 'Table'[Column1]
VAR Items =
SUBSTITUTE ( String, " - ", "|" )
RETURN
PATHITEM ( Items, 2 )

View solution in original post

@Jenny_Sommet 

Column2 =
VAR String = 'Table'[Column1]
VAR Items =
SUBSTITUTE ( String, " - ", "|" )

VAR Length = 

COALESCE ( PATHLENGTH ( Items ), 1 )
RETURN
PATHITEM ( Items, Length )

View solution in original post

4 REPLIES 4
Jenny_Sommet
New Member

@tamerj1  Really appreciate your support!

Jenny_Sommet
New Member

Thank you so much for the fast response! @tamerj1 

 

Can you confirm how I can modify the DAX to only extract the characters after '- ' also?

 

EDPC - 2023.Q1 - DP (want to extract DP)

LRM - 2023.1 - UG - DP (want to extract DP)

LRCM - 2022.2 - PG - DP (want to extract DP)

@Jenny_Sommet 

Column2 =
VAR String = 'Table'[Column1]
VAR Items =
SUBSTITUTE ( String, " - ", "|" )

VAR Length = 

COALESCE ( PATHLENGTH ( Items ), 1 )
RETURN
PATHITEM ( Items, Length )

tamerj1
Super User
Super User

Hi @Jenny_Sommet

Please try

Column2 =
VAR String = 'Table'[Column1]
VAR Items =
SUBSTITUTE ( String, " - ", "|" )
RETURN
PATHITEM ( Items, 2 )

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors