...
Info |
---|
NOTE: When the DOMAIN function parses a multi-tiered top-level domain such as co.uk , the output is the first part of the domain value (e.g. co ). To return other parts of the domain information, you can use the HOST function. See HOST Function. |
URL literal examples:
d-codelang-syntax |
---|
RawWrangle | true |
---|
Type | ref |
---|
showNote | true |
---|
WrangleText | derive type:single value: |
---|
| DOMAINdomain('http://www.example.com' ) as: 'myDomain' |
|
domain('http://www.example.com') |
Output: Generates a column containing Returns the value example
.
d-codelang-syntax |
---|
RawWrangle | true |
---|
Type | ref |
---|
showNote | true |
---|
WrangleText | derive type:single value: |
---|
| DOMAINdomain('http://www.exampl.e.com' ) as: 'myDomain' |
|
domain('http://www.exampl.e.com') |
Output: Generates a column containing Returns the value e
.
Column reference example:
d-codelang-syntax |
---|
RawWrangle | true |
---|
Type | ref |
---|
showNote | true |
---|
WrangleText | derive type:single value: |
---|
| DOMAINdomain(myURLs) as: 'myDomain' |
|
domain(myURLs) |
Output: Generates the new myDomain column containing the domain Returns the domain values extracted from the myURLs
column.
d-codelang-syntax |
---|
RawWrangle | true |
---|
Type | syntax |
---|
showNote | true |
---|
WrangleText | derive type:single value: |
---|
| DOMAIN |
domain(column_url) |
Argument | Required? | Data Type | Description |
---|
column_url | Y | string | Name of column or String or URL literal containing the domain value to extract |
...
Name | Referrer |
---|
Joe Guy | http://www.example.com |
Ian Holmes | http://www.test-value.com/support |
Nick Knight | http://www.test-value.com |
Axel Adams | http://www.example.com |
Teri Towns | http://www.example.com/test-value |
TransformTransformation:
The referrrer values include test-value
as a non-domain value and varying URLs from the test-value.com domain. So, you should use the DOMAIN
function to parse only the domain versions of these values. The following evaluates the Referrer
column values for the test-value
domain and generates true/false answers in a new column accordingly:
...
trans |
---|
RawWrangle | true |
---|
p03Value | 'isInternal' |
---|
Type | step |
---|
WrangleText | derive type:single value: |
---|
|
...
...
domain(Referrer)=='test-value',true,false) as:'isInternal' | p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | if(domain(Referrer)=='test-value',true,false) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
Now that these values are flagged, you can filter out the internal names:
...
trans |
---|
RawWrangle | true |
---|
p03Value | (isInternal == 'true') |
---|
Type | step |
---|
WrangleText | delete row:(isInternal == 'true') |
---|
p01Name | Condition |
---|
p01Value | Custom formula |
---|
p02Name | Type of formula |
---|
p02Value | Custom single |
---|
p03Name | Condition |
---|
p04Value | Delete matching rows |
---|
p04Name | Action |
---|
SearchTerm | Filter rows |
---|
|
Results:
Name | Referrer | isInternal |
---|
Joe Guy | http://www.example.com | false |
Axel Adams | http://www.example.com | false |
Teri Towns | http://www.example.com/test-value | false |
...