Skip to main content
swapnar6405
Known Participant
Jan 31, 2023 9:14 PM UTC
Solved

Need difference set of data from rule input, local variable.

Hi,

I have a rule input with multiple rows of data and I also have a local variable with few rows of data.

Now I want to find the difference rows of data into a another local variable.

Is it possible in appian. 

Any inputs please.

konduruc733182
Inspiring
Feb 1, 2023 5:19 AM UTC

Hello swapnar6405,

You can use symmetricDifference() to get the unique values that are there in both set A and set B.

Here is an example

a!localVariables(
  local!data1: {
    a!map(name: "kevin", age: "23", gender: "Male"),
    a!map(name: "Rambo", age: "26", gender: "Male"),
    a!map(name: "Jude", age: "33", gender: "Female"),
    a!map(
      name: "Michelle",
      age: "21",
      gender: "Female"
    )
  },
  local!data2: {
    a!map(name: "kevin", age: "23", gender: "Male"),
    a!map(
      name: "Fracesca",
      age: "22",
      gender: "Female"
    ),
    a!map(name: "Jude", age: "33", gender: "Female"),
    a!map(name: "Martin", age: "53", gender: "Male"),
    a!map(
      name: "Michelle",
      age: "21",
      gender: "Female"
    )
  },
  local!unique: symmetricdifference(local!data1, local!data2),
  { local!unique }
)

3 replies

mikes0011
Brainy
Jan 31, 2023 9:38 PM UTC

the cheap and easy way would be to use the difference() function.  It's probably picky about your data type, so it might be necessary to cast the local variable as the CDT type before passing it through that function.  Also note that it would return a difference even for the tiniest change in data.

The Expression Guru
konduruc733182
Inspiring
Feb 1, 2023 5:19 AM UTC

Hello swapnar6405,

You can use symmetricDifference() to get the unique values that are there in both set A and set B.

Here is an example

a!localVariables(
  local!data1: {
    a!map(name: "kevin", age: "23", gender: "Male"),
    a!map(name: "Rambo", age: "26", gender: "Male"),
    a!map(name: "Jude", age: "33", gender: "Female"),
    a!map(
      name: "Michelle",
      age: "21",
      gender: "Female"
    )
  },
  local!data2: {
    a!map(name: "kevin", age: "23", gender: "Male"),
    a!map(
      name: "Fracesca",
      age: "22",
      gender: "Female"
    ),
    a!map(name: "Jude", age: "33", gender: "Female"),
    a!map(name: "Martin", age: "53", gender: "Male"),
    a!map(
      name: "Michelle",
      age: "21",
      gender: "Female"
    )
  },
  local!unique: symmetricdifference(local!data1, local!data2),
  { local!unique }
)

swapnar6405
Known Participant
Feb 2, 2023 4:35 PM UTC

Thanks Chaitanya for your quick help with example.