Compare and get a count of expression

Hello ,

I have two expression rules, rule 1 & rule 2. I want to compare them and print its count into grid.

RULE 1

ABC

CDE

GHI

JKL

RULE 2

ABC

DEF

ABC

DEF

GHI

ABC

I want to compare rule 1 with rule 2 and count of match records to show in grid. Like

count 

for ABC count should be 3 and so on.

  Discussion posts and replies are publicly visible

Parents
  • load(
      local!rule1: {
        "ABC",
        "CDE",
        "GHI",
        "JKL",
        
      },
      local!rule2: {
        "ABC",
        "DEF",
        "ABC",
        "DEF",
        "GHI",
        "ABC"
      },
      local!data: a!forEach(
        items: local!rule1,
        expression: {
          value: fv!item,
          count: count(
            wherecontains(
              fv!item,
              local!rule2
            )
          )
        }
      ),
      a!gridField(
        label: "",
        data: local!data,
        columns: {
          a!gridColumn(
            label: "Value",
            value: fv!row.value
          ),
          a!gridColumn(
            label: "Count",
            value: fv!row.count
          )
        }
      )
    )



  • Thanks, getting below error. I am on 17.4

    Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!gridColumn [line 33]: Invalid function a!gridLayoutColumns

  • I modified the code as below but grid is showing empty.

    load(
    local!pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 10),
    local!rule1: {
    "ABC",
    "CDE",
    "GHI",
    "JKL",

    },
    local!rule2: {
    "ABC",
    "DEF",
    "ABC",
    "DEF",
    "GHI",
    "ABC"
    },
    local!data: a!forEach(
    items: local!rule1,
    expression: {
    value: fv!item,
    count: count(
    wherecontains(
    fv!item,
    local!rule2
    )
    )
    }
    ),
    a!gridField(
    label: "",
    totalCount: 10,
    columns: {
    a!gridTextColumn(
    label: "Value",
    value: fv!row.value
    ),
    a!gridTextColumn(
    label: "Count",
    value: fv!row.count
    )
    },
    value: local!pagingInfo,
    saveInto: local!pagingInfo
    )
    )

    Value
    Count
    No items available
  • 0
    Certified Senior Developer
    in reply to gauravp0003

    Hi It seems that you are using older version of Appian (As you have used a!gridTextColumn() in your modified code).

    Please try with below code. It should work.

    load(
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 10
      ),
      local!rule1: {
        "ABC",
        "CDE",
        "GHI",
        "JKL",
        
      },
      local!rule2: {
        "ABC",
        "DEF",
        "ABC",
        "DEF",
        "GHI",
        "ABC"
      },
      local!data: a!forEach(
        items: local!rule1,
        expression: {
          value: fv!item,
          count: count(
            wherecontains(
              fv!item,
              local!rule2
            )
          )
        }
      ),
      with(
        local!dataSubSet: todatasubset(
          local!data,
          local!pagingInfo
        ),
        a!gridField(
          label: "",
          totalCount: local!dataSubSet.totalCount,
          columns: {
            a!gridTextColumn(
              label: "Value",
              data: index(
                local!dataSubSet.data,
                "value",
                {}
              )
            ),
            a!gridTextColumn(
              label: "Count",
              data: index(
                local!dataSubSet.data,
                "count",
                {}
              )
            )
          },
          value: local!pagingInfo,
          saveInto: local!pagingInfo
        )
      )
    )

Reply
  • 0
    Certified Senior Developer
    in reply to gauravp0003

    Hi It seems that you are using older version of Appian (As you have used a!gridTextColumn() in your modified code).

    Please try with below code. It should work.

    load(
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 10
      ),
      local!rule1: {
        "ABC",
        "CDE",
        "GHI",
        "JKL",
        
      },
      local!rule2: {
        "ABC",
        "DEF",
        "ABC",
        "DEF",
        "GHI",
        "ABC"
      },
      local!data: a!forEach(
        items: local!rule1,
        expression: {
          value: fv!item,
          count: count(
            wherecontains(
              fv!item,
              local!rule2
            )
          )
        }
      ),
      with(
        local!dataSubSet: todatasubset(
          local!data,
          local!pagingInfo
        ),
        a!gridField(
          label: "",
          totalCount: local!dataSubSet.totalCount,
          columns: {
            a!gridTextColumn(
              label: "Value",
              data: index(
                local!dataSubSet.data,
                "value",
                {}
              )
            ),
            a!gridTextColumn(
              label: "Count",
              data: index(
                local!dataSubSet.data,
                "count",
                {}
              )
            )
          },
          value: local!pagingInfo,
          saveInto: local!pagingInfo
        )
      )
    )

Children
No Data