Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

extract unique values from list of strings

Certified Associate Developer

Hello, I have the following list of strings coming from a query: 

List of Text String - 4 items
"user1"(Text)
"user2"(Text)
"user2; user3"(Text)
"user4"(Text)

How  I can sort that so the final result will be list of strings of only unique values: 


Result:
"user1"(Text)
"user2"(Text)
"user3"(Text)
"user4"(Text)

  Discussion posts and replies are publicly visible

Parents
  • It looks like it's possible that there can be multiple values within a single text item - is that correct? Do you anticipate that it will always show with a semicolon separator if there are multiple values?

    If you are confident in the format, you should be able to do this with several steps: (1) split each item by the semicolon (2) combine them all into a single list and (3) use the union() function to return a unique list of items. Something like this should work:

    a!localVariables(
      local!data: {
        "user1",
        "user2",
        "user2; user3",
        "user4"
      },
      union(
        a!flatten(
          a!forEach(
            items: local!data,
            expression: trim(split(fv!item, ";"))
          )
        ),
        touniformstring({})
      )
    )

Reply
  • It looks like it's possible that there can be multiple values within a single text item - is that correct? Do you anticipate that it will always show with a semicolon separator if there are multiple values?

    If you are confident in the format, you should be able to do this with several steps: (1) split each item by the semicolon (2) combine them all into a single list and (3) use the union() function to return a unique list of items. Something like this should work:

    a!localVariables(
      local!data: {
        "user1",
        "user2",
        "user2; user3",
        "user4"
      },
      union(
        a!flatten(
          a!forEach(
            items: local!data,
            expression: trim(split(fv!item, ";"))
          )
        ),
        touniformstring({})
      )
    )

Children