Lookup hell... in over my head...

Trying to create a slice and need expression which does the following:

Use value of: Schedule[Range] to cross reference "Range Directory"[Range] and get the corresponding "Range Directory"[vState] value. This returns the two-letter state abbreviation. The tricky part dynamically referencing a column name based on the result of the first lookup.

Next cross reference "Range Directory"[vState] with "Range Filter"[<two-letter-state-code>]. if this value is true, return true, otherwise false.

IF( LOOKUP( LOOKUP(Schedule[Range], "Range Directory", [Range], [vState]), "Range Filter", [<two-letter-state-code>], [Value] ) = true, true, false )

I'm stuck on how to do the 2nd lookup, using the value of the first lookup to build the value of the query. The structure "Range Filter" table is a two-letter state code for every state as the column name. For example: "Range Filter"[AL]='true'.

The reason for making states the column names was this was the only way known to use the quick-edit buttons in the UI to make it very simple. All the user sees in the view is: <State Code>: ON/OFF on a single row for each state.  Structuring the table in any other format prevented this clean/simple looking view.

Solved Solved
0 7 178
1 ACCEPTED SOLUTION

This works!


SWITCH(
LOOKUP([_THISROW].[Range], "Range Directory", "Range", "vState"),
"AL", INDEX(Range Filter[AL], 1),
"AK", INDEX(Range Filter[AK], 1),
"AZ", INDEX(Range Filter[AZ], 1),
...
...
"WY", INDEX(Range Filter[WY], 1),
FALSE
)

View solution in original post

7 REPLIES 7
Top Labels in this Space