Forum Discussion

diablo9081's avatar
diablo9081
Frequent Visitor
7 months ago
Solved

Lookup Value From Within Virtual Table

I need some help with how to lookup a value from within a virtual table. LOOKUPVALUE doesn't seem to work with virtual tables.   I've got the following: DEFINE VAR __DS0Core = SUMMARIZECOLUMNS(...
  • OwenAuger's avatar
    7 months ago

    Hi diablo9081 

    You could perform a lookup-equivalent with an expression like this:

    SELECTCOLUMNS (
        FILTER ( __DataTransformT0, [v_Clinic_Decode] = "<LOOKUP_VALUE>" ),
        [ClusterId]
    )

    Assuming __DataTransformT0 is guaranteed to contain at most one row per v_Clinic_Decode (which should be the case here), this would return a 1x1 table (or BLANK) which is automatically converted to a scalar value where required.

     

    Alternatively, you could consider using DEFINE TABLE rather than DEFINE VAR for __DataTransformT0 which would create a table for the duration of the query. You could then reference this table as though it were a model table in an expression like this:

    LOOKUPVALUE (
        __DataTransformT0[ClusterId],
        __DataTransformT0[v_Clinic_Decode], "<LOOKUP_VALUE>" )
    )

    See here.