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
Obrycki
Regular Visitor

DAX: SUBSTITUE Instance not dynamic

In Power BI Desktop I'm attempting to dynamically determine the last instance of a character and SUBSTITUTE that character with another. The following DAX formula appears to work in Excel but does not work in Power BI Desktop.

 

Column1 = test1_test2_test3

Formula: Last_Replaced = Last_Replaced = SUBSTITUTE(table1[Column1],"_","@",LEN(table1[Column1])-LEN(SUBSTITUTE(table1[Column1],"_","")))

This returns "An argument of function 'SUBSTITUTE has the wrong data type or has an invalid value."

However, if I set the number to 2 in the forumla it works.

If I first create a column that determines the value and holds this then include that new column in the formula it fails with the same error. 

 

Is this by design, a bug, or is there another way to accomplish what I'm trying to do in Power BI Desktop?

 

Thank you,

Trav

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Replace your underscore "_"  with a pipe "|"  and use the PATH functions.

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

Replace your underscore "_"  with a pipe "|"  and use the PATH functions.

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.