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 September 15. Request your voucher.

Reply
markefrody
Post Patron
Post Patron

Removing Characters Starting From Dash via DAX

Hi,

 

I'm trying to remove all characters starting from the dash symbol onwards. If possible via DAX. I'm using Direct Query.

Example 1:
Before: 12345-6789
After: 12345

Example 2:
Before: 1A3-12B
After: 1A3 

Appreciate your kind assistance.

Best regards,
Mark V.

1 ACCEPTED SOLUTION
HoangHugo
Solution Specialist
Solution Specialist

hi

 

After = IF(SEARCH("-",[text column],1,0)>=1,LEFT([text column],SEARCH("-",[text column],1,0)-1),[text column])

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @markefrody ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_1-1667445467986.png

2. create a measure with below dax formula

After =
VAR cur_val =
    SELECTEDVALUE ( 'Table'[Before] )
VAR cur_index =
    FIND ( "-", cur_val,, -1 )
RETURN
    LEFT ( cur_val, cur_index - 1 )

3 add a table visual with fields and measure

vbinbinyumsft_0-1667445404591.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for your assistance @Anonymous. Greatly appreciate it. 

HoangHugo
Solution Specialist
Solution Specialist

hi

 

After = IF(SEARCH("-",[text column],1,0)>=1,LEFT([text column],SEARCH("-",[text column],1,0)-1),[text column])

Thank you @HoangHugo. This works for me. Greatly appreciate your help!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors