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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
johnwedeles
Helper III
Helper III

Replacing text in column with new text based on condition

Hello:

 

I am trying to replace a hyphen ("-") with an en dash in an existing column. I know I'd need to use UNICHAR for this. So, I imagine the formula would be something like this:

 

IF Table Name Column Name contains "-", replace with UNICHAR(8211)

 

I don't mind creating a new column or measure if that is necessary.

 

Thank you!

1 ACCEPTED SOLUTION

@johnwedeles 

if it is a value in a cell, use substitute

Column = SUBSTITUTE('Table'[Column1],"-",UNICHAR(8211))

1.PNG

if it is the name of a measure, you replace the whole measure name

2.PNG

2.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

12 REPLIES 12
ryan_mayu
Super User
Super User

@johnwedeles 

you can use DAX to create a column

Column = SUBSTITUTE("-",'Table'[Column1],UNICHAR(8211))

1.PNG 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you, @Greg_Deckler  and @ryan_mayu . I tried both the REPLACE and SUBSTITUTE functions, and unfortunately when I try to select the appropriate table and column, the specific column does not show up as an option. Note, it is a string variable. I get an error message saying that "a single value for this column cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."

 

 

@johnwedeles - If you are creating a measure, then you will need to wrap the column reference in an aggregator like MAX, MIN, etc.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thank you, @Greg_Deckler . I am entering this code but it is not working - is the right placement for the MAX function?

 

Measure = SUBSTITUTE(MAX('Performance rates'[New Rate Definition])"-",UNICHAR(8211)))

@johnwedeles 

plesae share the sample data and expected output.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu the string I am working with appears as follows:

 

Ambulatory Care: Emergency Department (ED) Visits: Ages 0-19 Years

 

This is an example of several (approximately 40) measures that are in the table. What I would like to do is replace the hypen (Ages 0-19 Years) with an en dash, using UNICHAR.

@johnwedeles 

why this is a measure? not a value in a cell? How did you calculate this? you can just paste your sample data here or paste a screenshot





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you, @ryan_mayu . Here are two screenshots.

 

johnwedeles_0-1595605051563.pngjohnwedeles_1-1595605112650.png

 

 

@johnwedeles 

if it is a value in a cell, use substitute

Column = SUBSTITUTE('Table'[Column1],"-",UNICHAR(8211))

1.PNG

if it is the name of a measure, you replace the whole measure name

2.PNG

2.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you, @ryan_mayu !

Thank you, @ryan_mayu . I don't have the ability to attach a file here. 

 

 

Greg_Deckler
Community Champion
Community Champion

To do this in DAX, just use a new calculated column with REPLACE

https://docs.microsoft.com/en-us/dax/replace-function-dax

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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
Top Kudoed Authors