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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Get value by delimiter in dax

jeongkim_0-1758093812708.png

 

how can I get before 2nd delimiter(-) values?

e.g. G-333437PD8

 

1 ACCEPTED SOLUTION

Here is another alternate 

Alternate_Before_2nd_Delimiter = 
VAR FirstHyphen = IFERROR(FIND("-", 'Data'[Column], 1), 0)
VAR SecondHyphen = IFERROR(FIND("-", 'Data'[Column], FirstHyphen + 1), 0)
RETURN 
    SWITCH(
        TRUE(),
        SecondHyphen = 0, 'Data'[Column],  
        LEFT('Data'[Column], SecondHyphen - 1)
    )

View solution in original post

5 REPLIES 5
rohit1991
Super User
Super User

Hi @Anonymous 

Could you please try below Calculated Column :

Extract_Before_2ndDash =
VAR InputText = 'Table'[Column Name]
VAR FirstDash = SEARCH("-", InputText, 1)
VAR SecondDash = SEARCH("-", InputText, FirstDash + 1)
RETURN
    LEFT(InputText, SecondDash - 1)


image.png

 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!
Anonymous
Not applicable

maybe this doesn't find blank value? still got error. 

VAR InputText = 'Table'[Column Name]
VAR FirstDash = SEARCH("-", InputText, 1)
VAR SecondDash = SEARCH("-", InputText, FirstDash + 1)
RETURN
    LEFT(InputText, SecondDash - 1)

 

Royel
Solution Sage
Solution Sage

HI @Anonymous  you can try this 

Before_2nd_Delimiter = 
VAR ModifiedString = SUBSTITUTE(Data[Column], "-", "|", 2)
VAR SecondDelimiterPos = FIND("|", ModifiedString, 1)
RETURN 
    IF(
        ISERROR(SecondDelimiterPos),
        Data[Column],
        LEFT(Data[Column], SecondDelimiterPos - 1)
    )

Results: 

Royel_0-1758095495261.png

Find this helpful? ✔ Give a Kudo • Mark as Solution – help others too!

Anonymous
Not applicable

Hi,

Got error this

jeongkim_0-1758095765079.png

 

Here is another alternate 

Alternate_Before_2nd_Delimiter = 
VAR FirstHyphen = IFERROR(FIND("-", 'Data'[Column], 1), 0)
VAR SecondHyphen = IFERROR(FIND("-", 'Data'[Column], FirstHyphen + 1), 0)
RETURN 
    SWITCH(
        TRUE(),
        SecondHyphen = 0, 'Data'[Column],  
        LEFT('Data'[Column], SecondHyphen - 1)
    )

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors