The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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.
Solved! Go to Solution.
hi
After = IF(SEARCH("-",[text column],1,0)>=1,LEFT([text column],SEARCH("-",[text column],1,0)-1),[text column])
Hi @markefrody ,
Please try below steps:
1. below is my test table
Table:
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
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.
hi
After = IF(SEARCH("-",[text column],1,0)>=1,LEFT([text column],SEARCH("-",[text column],1,0)-1),[text column])