How do I add a virtual column that contains value from a column in another table based on a set of conditions?

I want to add a virtual column โ€˜Zoneโ€™ in โ€˜Orderโ€™ table where the value is derived from โ€˜Zoneโ€™ column in a reference table โ€˜Allocationโ€™; based on the condition that the โ€˜Postal codeโ€™ fits the postal code range in the reference table. E.g.
Order
Address
Postal Code
Zone <<< virtual column

Allocation
Zone
Postal Code From
Postal Code To

What is the expression to use for the virtual column?

Thanks.

Solved Solved
0 2 160
1 ACCEPTED SOLUTION

Hi @christopher.looi ,

See if this works:

SORT(SELECT(Allocation[Zone],AND(
    [Postal Code From]<=[_THISROW].[Zone],
    [Postal Code To]  >=[_THISROW].[Zone]

)))

If it doesnโ€™t work, please post a picture of your column names/settings.

View solution in original post

2 REPLIES 2

Hi @christopher.looi ,

See if this works:

SORT(SELECT(Allocation[Zone],AND(
    [Postal Code From]<=[_THISROW].[Zone],
    [Postal Code To]  >=[_THISROW].[Zone]

)))

If it doesnโ€™t work, please post a picture of your column names/settings.

@GreenFlux It works! Thanks!

Top Labels in this Space