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.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive