Skip to main content
Participating Frequently
Mar 31, 2023 10:05 AM UTC
Solved

How can I index multiple values of a constant

Hi,

I have a constant which contains array of text, I want to check if a given value is in the array subset of that constant.

For that I'm using-

contains(

{

cons!TA_CITY_LABEL[1],

cons!TA_CITY_LABEL[3],

cons!TA_CITY_LABEL[4],

cons!TA_CITY_LABEL[7]

.

.

.

and many more

},

local!label

)

I wonder if there is any solution to it as I have to write the name of constant again and again and I'm checking this multiple times on different datasets.

    sanchitg0002
    Inspiring
    Mar 31, 2023 10:07 AM UTC

    You can use it like cons!name[array of indices], this will save you much time.

    contains(
      cons!TA_CITY_LABEL[{ 1, 3, 4, 7 }],
      local!label
    )

    9 replies

    sanchitg0002
    Inspiring
    Mar 31, 2023 10:07 AM UTC

    You can use it like cons!name[array of indices], this will save you much time.

    contains(
      cons!TA_CITY_LABEL[{ 1, 3, 4, 7 }],
      local!label
    )

    harshitb6843
    Brainy
    Mar 31, 2023 10:08 AM UTC

    Oh god! What type of hacks have you started writing, Sanchit?

    sanchitg0002
    Inspiring
    Mar 31, 2023 10:11 AM UTC

    Why? is there anything wrong in that? [emoticon:5ce50ea3f9eb49809e861e8733750338]

    harshitb6843
    Brainy
    Mar 31, 2023 10:08 AM UTC

    index(cons!TA_CITY_LABEL,{1,2,3,4},{})

    Participating Frequently
    Mar 31, 2023 10:18 AM UTC

    Oh no I should have done it myself, but what Sanchit suggested above is amazing. Thanks for the help

    sanchitg0002
    Inspiring
    Mar 31, 2023 10:32 AM UTC

    Okay, but then I'm not responsible for the things Harshit said above [emoticon:c4563cd7d5574777a71c318021cbbcc8]