Skip to main content
Known Participant
Jan 19, 2023 10:57 AM UTC
Question

queryentity group by with custom output

Hi All,

I have a table with

studentid|subjectid

1     | 10

1     | 11

2     | 12

Students who belong to 10 and 11 should get 1|Science, 2|Maths.

How can I get the output like this. 

      

    1 reply

    konduruc733182
    Inspiring
    Jan 19, 2023 7:54 PM UTC

    Hello rupaa0642,

    You can use the displayValue() function in the interface and use a constant that contains your subject names and replace the integers with the values.

    You can also try to have a reference table which has the values of all subject names and you can store the respective ID with the student Id. So that you can simply query the value based on your ID. 

    Below is an example how you can use the displayValue() and achieve your requirement. You can replace the subject names with the constant.

    a!localVariables(
      local!data:{
        a!map(
          studentId:10,
          subjectId:1
        ),
        a!map(
          studentId:11,
          subjectId:1
        ),
        a!map(
          studentId:12,
          subjectId:2
        )
      },
      {
        a!gridField(
          data: local!data,
          columns: {
            a!gridColumn(
              label: "Student Id",
              value: index(fv!row,"studentId",null)
            ),
            a!gridColumn(
              label: "Subject Id",
              value: displayvalue(
                index(fv!row,"subjectId",null),
                {1,2,3},
                {"Science","Maths","English"},
                "-"
              )
            )
          }
        )
      }
    )