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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Dn_wemn
Helper II
Helper II

Cut delimeter if it's at the end of text value

Hi all,

I'd like to cut out the delimeter "-" if it's at the last position of the value. So every text value should not have - at the end.

Dn_wemn_1-1697097428906.png

How can this be done? Thanks.

1 ACCEPTED SOLUTION
dk_dk
Super User
Super User

Does your data contain the delimiter in any other position (for instance "ab-cdef")?

If not, you could simply use replace value, and replace "-" with "".

If yes, then:

Add column - > extract-> last 1 character.

Add column -> extract -> text before delimiter, scan from end of input:

dk_dk_0-1697100091586.png

 

Then add a conditional column:

dk_dk_1-1697100210863.png

Column1 would be your ID column here.

Then your data will look something like this:

dk_dk_2-1697100272878.png

note how the - is removed only from the end of string, not the middle.

You can keep the custom column and delete the other 3 now.


I hope this helps, let me know if you have any questions.







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

Proud to be a Super User!





View solution in original post

5 REPLIES 5
Uzi2019
Super User
Super User

Hi @Dn_wemn ,
Please create calculated column for your solution.

Uzi2019_0-1697100329847.png

If this helps you please give kudos and accept my solution!
Thanks

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
dk_dk
Super User
Super User

Does your data contain the delimiter in any other position (for instance "ab-cdef")?

If not, you could simply use replace value, and replace "-" with "".

If yes, then:

Add column - > extract-> last 1 character.

Add column -> extract -> text before delimiter, scan from end of input:

dk_dk_0-1697100091586.png

 

Then add a conditional column:

dk_dk_1-1697100210863.png

Column1 would be your ID column here.

Then your data will look something like this:

dk_dk_2-1697100272878.png

note how the - is removed only from the end of string, not the middle.

You can keep the custom column and delete the other 3 now.


I hope this helps, let me know if you have any questions.







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

Proud to be a Super User!





It works here, but in my productive report which is Directquery, these steps are not allowed. 

 

If you have a live connection to a database, then you should try to set these conditions in the datasource itself, before you connect to it in Power BI. Do you have access to the database you are connecting to?

Alternatively you could try to make Uzi's solution but as measure, instead of calculated column, but I am not sure it would work.




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

Proud to be a Super User!





HI, thanks for your answer. Its a direct query to Dataverse, so there is no database.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.