Combining datasets by looking for strings in one column
I have a couple datasets... 1) Product IDs with information 2) Google Analytics data with URLs that contain the product IDs on product pages
I'd like to join the first dataset to the GA data to include product information that aligns with the product page. Is there a way to join these datasets in which I have the second dataset look for a product ID that is contained in the URL and match accordingly?
Example:
Dataset 1
Answers
-
Do the URLs have a consistent format to them? If so, you can use the formula tile in Magic ETL to extract the ID at the end of the URL to create a new column called Product ID. You can then use the Join tile in Magic ETL and join the two datasets together. An example to use for the formula tile based on the two samples you gave would be to use the RIGHT function and extract the last 6 characters like this:
RIGHT(url,6)
This would get the product ID from the URL for you.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
They have the product ID at the end of the URL... however the Product IDs come in different lengths. They are however preceded by a '/' ex: https://climate.emerson.com/en-us/shop/1/copeland-sku-zp20kae-pfv-130
So, I suppose I could try and pull out the last segment after a '/'. How would I do that?
0 -
I like to use the SPLIT_PART() function for this. It would look something like this:
SPLIT_PART(url,'/',7)
This should return everything after the last slash (i.e. copeland-sku-zp20kae-pfv-130)
SPLIT_PART(STR,SEP,N)
Returns the Nth substring of str split by sep. If N is zero or smaller, returns null. If there are fewer than N substrings after str has been split by the given separator, returns empty string.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
There might be a different number of '/' though for each URL... I also noticed this has "Copeland-sku-" in front of the part number.... maybe I can use the sku- as a deliminator.
0 -
Yes, try SPLIT_PART(url,'copeland-sku',2) and see if that gets you what you want.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
Hi @User_32265
Regular expressions are a great tool for this use case when you're trying to parse our text from another with variable length or positioning. You can utilize this regular expression in a formula tile:
REGEXP_REPLACE(`url`, '^.*/([^/]*)$', '$1')
^
Says start at the beginning of the string.*
Match any number of any character/
Explicitly matches the forward slash()
Captures the group so we can replace the text in the second parameter[^/]*
Matches any non-forward slash character 0 or more times$
Matches the end of the stringIn layman's terms we're saying return to me the characters at the end of the string after the last forward slash.
$1
says to replace all of the text we found in the first part with the first matching group (what we saved from the regular expression using()
)**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
Thanks all... I've learned that not all the pages end in the product id... going back to my original question. Is there a way to look for strings contained in a field in order to match from another dataset with a field that contains that string?
0 -
Magic ETL doesn't support conditional joins so you'd need to set a constant for each of your datasets called 'Join Column' and set to a value of 1, then do a join on both datasets together. After that you can use this expression to filter your results.
`URL` LIKE CONCAT('%', `Product ID`, '%')
Not the most efficient method as it'll do a Cartesian join and then filter instead of filtering on the join (removing the amount of data needed to process).
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
Thanks Grant.
0
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
- 754 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 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