Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Trim right digits after last -

kas
8 - Asteroid

Hello,

 

I am using the formula below in a formula tool, but in instances where there are double digits after the last dash, it only removes one. (if I put 2 it will remove the "-" when a single digit). Have tried several different ways without success. Tried a RegEx, but I'm not the most versed with them and didn't get it quite right either.

 

TrimRight([Name],Right([Name], 1))

 

 

 

Current Desired
   
   
Name Name
Fund-Number-9 Fund-Number-
Fund-Name-9 Fund-Name-
Fund-Type-9 Fund-Type-
Fund-Transaction-Amount-9 Fund-Transaction-Amount-
Fund-Units-Sold/Purchased-9 Fund-Units-Sold/Purchased-
Fund-Ending-Units-9 Fund-Ending-Units-
Fund-Unit Val-9 Fund-Unit Val-
Fund-Ending-Value-9 Fund-Ending-Value-
Fund-Number-10 Fund-Number-
Fund-Name-10 Fund-Name-
Fund-Type-10 Fund-Type-
Fund-Transaction-Amount-10 Fund-Transaction-Amount-
Fund-Units-Sold/Purchased-10 Fund-Units-Sold/Purchased-

 

Thank you,

Kim

2 REPLIES 2
ChrisTX
16 - Nebula
16 - Nebula

Try this in a Formula tool

 

REGEX_Replace([Name], "(.*-).*", "$1")

 

kas
8 - Asteroid

@ChrisTX - works like a charm...thanks so much for the quick solution!

Labels
Top Solution Authors