Hi,
I have two data sources and I would like to create a column that says "true" when one variable is between two other variables from another data source
Source 1:
Name | Val |
A | 1 |
A | 2 |
A | 3 |
A | 4 |
A | 5 |
A | 6 |
A | 7 |
A | 8 |
A | 9 |
A | 10 |
B | 1 |
B | 2 |
B | 3 |
B | 4 |
Source 2:
Name | Start | End |
A | 3 | 5 |
A | 8 | 9 |
B | 1 | 2 |
I would like the end result to look like
Name | Val | In-between |
A | 1 | false |
A | 2 | false |
A | 3 | true |
A | 4 | true |
A | 5 | true |
A | 6 | false |
A | 7 | false |
A | 8 | true |
A | 9 | true |
A | 10 | true |
B | 1 | true |
B | 2 | true |
B | 3 | false |
B | 4 | false |
I'm struggling to figure out to get achieve this. I'm pretty sure I would need to write the formula Val >= Start && Val <= End at some point, but I'm not sure how to put everything together. Is it possible?
Thanks
Solved! Go to Solution.
Looking at your sample data you can have multiple ranges for each name.
I'd suggest:
- Join the two tables on name (this will create duplicates from first table)
- Create a filter where val between start and end
- Use a unique to remove duplicated from the true output
- Join again to the original table A
- Use a formula tool on L and J outputs to make the T/F column
- Union results
Sample attached
Thanks @jdunkerley79 and @ivoller!