Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Match value to an array in load script

I have shipping orders with a FromState and a ToState.  I am trying to determine if the orders are within the same state and within the United States.  We also have counrtry codes like CN for Canada, hence the need for the 50 state variable.

I have created a load inline for all 50 states.

LOAD * INLINE [

    State

    AK

    AL

    AR

    AZ

    CA

    CO

    ...etc.

];

Placed these into an Array of vStates and then tried the following.

   if(FromState = ToState and match(FromState, $(vStates)), 'SameState') as IsFromUSState

The Variable loads fine without the formula above in the load statement for use within the document.

but the formula above gets the error:


Field not found - <AK>

LOAD

     FromState,

     ToState,

     Qty,

      AK,AL,AR,AZ,CA,CO,CT,DC,DE,FL,GA,HI,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VA,VT,WA,WI,WV,WY as IsFromUSState

FROM

[..\MyTable.qvd]

(qvd)

as if it's trying to load the States from MyTable vs. matching them against the variable.

Thanks

2 Replies
danielrozental
Master II
Master II

You should use exists in this case

Where exists(State, fromState)

vgutkovsky
Master II
Master II

Or, more accurately: if(FromState = ToState and exists(State,FromState),'SameState') as IsFromUSState

Regards,

Vlad