Changing data from text to integer
Hey there,
I have a Webhook data coming from Wix that looks like the following "VIC Player Hosting Fee (April Cloth Camp) AUD 87.00". I need to seperate the monetary value at the end of the string and convert from text to integer, but have tried using methods like CAST and the Alter Columns MagicETL tile to no avail. Any suggestions of best practice here?
Best Answer
-
REGEXP_REPLACE(`field`, '^.* ([^ ]+)$', '$1') * 1
this should find the last value in your string after the last space. Multiplying it by 1 will convert it to a number.Will the numbers be always at the end or anywhere in the string preceded by AUD?
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1
Answers
-
Have you already separated out the monetary value from the string?
If not, my recommendation would be to figure out a consistent way to identify the location of the value you want to extract, and then use Regex to get that value.
You’ll want to make sure there is no white space around the extracted value
from there converting to a numeric value should be possible using the alter tileDavid Cunningham
** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
** Did this solve your problem? Accept it as a solution! ✔️**0 -
REGEXP_REPLACE(`field`, '^.* ([^ ]+)$', '$1') * 1
this should find the last value in your string after the last space. Multiplying it by 1 will convert it to a number.Will the numbers be always at the end or anywhere in the string preceded by AUD?
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
Hey Grant, they will always be at the end of the string, following "AU". I'll give this a try, cheers!
0 -
@GrantSmith I'm getting the error "Failed to convert value 'Fee' from type 'String' to type 'Floating Decimal'.
0 -
hi, i am not sure what i am missing but This calculation is using a nonexistent function
0 -
@German_Rodriguez - there are a couple of functions that work that are not listed in the official documentation. There are also functions that exist in MagicETL, that do not exist in Beast Mode (and vice versa). In this case, REGEX_REPLACE is a listed MagicETL function.
David Cunningham
** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
** Did this solve your problem? Accept it as a solution! ✔️**1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 738 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive