How to count frequency of data in dataset

Hi ,

 

Do we have any function in appian which can count frequency of data in dataset.

Test Dataset -

             Column 1 Column 2 Column 3

 Row 1 -     A           B             C

 Row 2-      A           B             D

 Row 3 -     C           B             E

 Row 4-      C           A             F

 Row 5-      C           G             H

 

Here i want to put one validation that combination of row 1 and row 2 should not be same . For that i need one frequency function which can return frequency of data in Column A & Column B. Here we have A & B coming in two rows which should not like that.

 

Kindly help me if anyone knows this.

I need to put one validation rule which should check frequency of

  Discussion posts and replies are publicly visible

Parents
  • I'm assuming you mean this is a grid that is presented to the user and not data that's coming from the database. While there's no out-of-the-box rule that will give you this, the following expression can serve as a starting point:

    = load(
      local!data: {
        { c1: "A", c2: "B", c3: "C" },
        { c1: "A", c2: "B", c3: "D" },
        { c1: "C", c2: "B", c3: "E" },
        { c1: "C", c2: "A", c3: "F" },
        { c1: "C", c2: "G", c3: "H" }
      },
      
      a!foreach(
        items: local!data,
        expression: with(
          difference(
            intersection(
              wherecontains(property(fv!item, "c1", null), property(local!data, "c1", null)),
              wherecontains(property(fv!item, "c2", null), property(local!data, "c2", null))
            ),
            fv!index
          )
        )
      )
    )
    

    This expression returns an array containing the rows that contain the same keys (in your case, c1 and c2), and an empty array if there are no matching rows at that index. It probably won't scale very well, so please keep an eye on performance for your specific data sets.

    If you're trying to check this for data that's already in the database, I would suggest you do this in the database server and not in Appian.

Reply
  • I'm assuming you mean this is a grid that is presented to the user and not data that's coming from the database. While there's no out-of-the-box rule that will give you this, the following expression can serve as a starting point:

    = load(
      local!data: {
        { c1: "A", c2: "B", c3: "C" },
        { c1: "A", c2: "B", c3: "D" },
        { c1: "C", c2: "B", c3: "E" },
        { c1: "C", c2: "A", c3: "F" },
        { c1: "C", c2: "G", c3: "H" }
      },
      
      a!foreach(
        items: local!data,
        expression: with(
          difference(
            intersection(
              wherecontains(property(fv!item, "c1", null), property(local!data, "c1", null)),
              wherecontains(property(fv!item, "c2", null), property(local!data, "c2", null))
            ),
            fv!index
          )
        )
      )
    )
    

    This expression returns an array containing the rows that contain the same keys (in your case, c1 and c2), and an empty array if there are no matching rows at that index. It probably won't scale very well, so please keep an eye on performance for your specific data sets.

    If you're trying to check this for data that's already in the database, I would suggest you do this in the database server and not in Appian.

Children