Skip to main content
Known Participant
October 10, 2023
Question

How to remove duplicate index form local(Array)

  • October 10, 2023
  • 4 replies
  • 3 views

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
    October 10, 2023

    Hi ,

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

    rishikeshr4182
    Inspiring
    October 10, 2023

    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
    October 26, 2023

    How to keep only unique based on the dept value? 

    rishikeshr4182
    Inspiring
    October 27, 2023

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

    Rishikesh