User Tools

Site Tools


transformations:intervalmerge

INTERVAL MERGE

Category: Transform / Advanced


Description

This action merges two tables based on whether a value in one table falls into a range specified by two values in another table.

The lower boundary of a range is inclusive, the upper is exclusive. Ranges can overlap. In such cases, one row for each match will be inserted into the resulting table.


Use cases

Interval merge can be used to to categorize or "bucket" values in a dataset that fall within a given range or scale, such as survey responses (1-3 = "bad", 4-6 = "neutral", 7-10 = "good"), temperature ranges, size scales, etc.

This action is a good substitute for a Lookup action that uses multiple lookup values with similar return values (e.g., 1="good", 2="good", 3="neutral", 4="bad", 5="bad).


Action settings

SettingDescription
Merge tableSelect the table to merge with the current dataset.
ColumnsSelect whether to merge all columns in the second dataset, or just selected columns. Options: All columns or
Selected columns (choose which columns to include in the merge).

The reference to the second table will appear as a dotted line connecting this action to the second dataset in the application window.


Remarks

To create a lookup set that doesn't contain any "gaps" be sure to set the "less than" value one higher than the last value you want to be included in the range, and start the following pairing with that same value.

Low High Label
0 4 Range is 0 to 3
4 8 Range is 4 to 7 (don't start with "5" or you'll lose "4")
8 11 Range is 8 to 10. (range end is "10" as "11" is excluded)


A lookup pair (low, high) cannot have a "high" value that is equal to the "low" value. This pairing will not return a match as there is no upper threshold. e.g. with "1" as the low value and "1" (exclusive) as the high value, no actual upper threshold has been defined.

Interval merge can also use text-based lookup ranges and values (see Example 2, below).


Examples

Example 1: Find what it feels like in Toronto during the year.

Table 1: Temperature in Toronto (Celsius)

Month Temp High (C)
Jan 0
Feb 0
Mar 4
Apr 12
May 19
Jun 24
Jul 27
Aug 26
Sep 23
Oct 15
Nov 9
Dec 3

Table 2: Boundaries

Lower Upper Feels
0 15Cold
15 25Comfortable
25 99Hot


Action parameters:

Table to merge is "Table 2"
Values in column (Table 1) is "Temp High (C)"
Are greater than or equal to "Lower" (in Table 2)
And less than "Upper" (in Table 2)


Result table:

Month High, C Feels
Jan 0Cold
Feb 0Cold
Mar 4Cold
Apr 12Cold
May 19Comfortable
Jun 24Comfortable
Jul 27Hot
Aug 26Hot
Sep 23Comfortable
Oct 15Comfortable
Nov 9Cold
Dec 3Cold



Example 2: Use a letter-based merge to assign Names to letter ranges.

Table 1: Names

Name
Mary
Sally
Bob
Max
Bruce
Tammy
Chris
Frank
Zeek

Table 2: Lookup ranges

Low High Label
A F Range A-E
F L Range F-K
L S Range L-R
S Z Range S-Y
Z Zz Range Z

The high value of "Zz" is used in the last record since the low value cannot be the
same as the high value. See Remarks, above.


Action parameters:

Table to merge is "Table 2"
Values in column "Name" (Table 1)
Are greater or equal to "Low" (Table 2)
And less than "High" (Table 2)
Columns to merge is "Label"


Result table:

Name Label
Mary Range L-R
Sally Range S-Y
Bob Range A-E
Max Range L-R
Bruce Range A-E
Tammy Range S-Y
Chris Range A-E
Frank Range F-K
Zeek Range Z


Community examples


See also

transformations/intervalmerge.txt · Last modified: 2021/07/19 02:24 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki