sum a values in a column

I want to get the sum of values from a column in the expression editor and I want to use that expression object in an interface to show my Sum which I calculated.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I am not really sure what you are looking for. But to calculate the sum of all values of a field in a list of records have a look at this code snippet:

    a!localVariables(
      local!test1: {
        {
          item: "stapler",
          name: "Mike",
          countryId: 1
        },
        {
          item: "printer",
          name: "Larrys",
          countryId: 2
        },
        {
          item: "printer",
          name: "Larry",
          countryId: 2
        },
        {
          item: "laptop",
          name: "Mike",
          countryId: 1
        },
        {
          item: "glass",
          name: "Mike",
          countryId: 3
        }
      },
    
    
      sum(local!test1.countryId)
    )

Reply
  • 0
    Certified Lead Developer

    I am not really sure what you are looking for. But to calculate the sum of all values of a field in a list of records have a look at this code snippet:

    a!localVariables(
      local!test1: {
        {
          item: "stapler",
          name: "Mike",
          countryId: 1
        },
        {
          item: "printer",
          name: "Larrys",
          countryId: 2
        },
        {
          item: "printer",
          name: "Larry",
          countryId: 2
        },
        {
          item: "laptop",
          name: "Mike",
          countryId: 1
        },
        {
          item: "glass",
          name: "Mike",
          countryId: 3
        }
      },
    
    
      sum(local!test1.countryId)
    )

Children
No Data