Skip to main content
Known Participant
Oct 10, 2023 2:41 AM UTC
Question

How to remove duplicate index form local(Array)

Hi  i have a requirement to show only unique index value while using for each

how can i do that ?

in local!voucher Details have 4 item that is duplicate i need only unique value

    4 replies

    shikhat
    Inspiring
    Oct 10, 2023 6:00 AM UTC

    Hi ,

    You can use union function to get distinct values .
    union(local!voucherDetails,local!voucherDetails)

    rishikeshr4182
    Inspiring
    Oct 10, 2023 6:34 AM UTC

    I have tried to replicate your use, plz refer this.


    a!localVariables(
      local!test: {
        {
          username: "",
          buduget: 2023,
          dept: 123456789
        },
        {
          username: "",
          buduget: 2023,
          dept: 123456789
        },
        {
          username: "Rishikesh",
          buduget: 2023,
          dept: 123
        },
        {
          username: "Rishikesh",
          buduget: 2023,
          dept: 123
        },
        {
          username: "Rishikesh",
          buduget: 2023,
          dept: 123
        }
      },
      union(local!test, local!test)
    )

    Rishikesh
    natarajanm0529
    Known Participant
    Oct 26, 2023 3:59 PM UTC

    How to keep only unique based on the dept value? 

    rishikeshr4182
    Inspiring
    Oct 27, 2023 5:13 AM UTC

    you can use the union function, it compares all the fields. 

    Rishikesh