Skip to main content
Known Participant
May 16, 2023 11:09 AM UTC
Solved

Generate Report (Column Charts) from Expression Rule

I want to generate a Column Chart from Expression rule which contains query aggregation on two columns , How can I generate a Column Chart for this.

Below is the code of my Expression Rule

index(
  a!queryEntity(
    entity: cons!MBUA_DSE_TESTSITEDATA,
    query: a!query(
      aggregation: a!queryAggregation(
        {
          a!queryAggregationColumn(field: "site", isGrouping: true()),
          a!queryAggregationColumn(field: "worktype", isGrouping: true()),

        }
      ),
      pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 50)
    ),
    fetchTotalCount: false
  ),
  "data",
  null()
)

Below is the code on Interface having Column Chart:

a!localVariables(
  local!myData: rule!MBUA_readChartView(),
  {
    a!columnChartField(
      label: "Column Chart",
      categories: { "Category 1", "Category 2" },
      series: a!forEach(
        items: local!myData,
        expression: a!chartSeries(label: "Chart", data: fv!item.worktype)
      ),
      stacking: "NONE",
      showLegend: true,
      showTooltips: true,
      labelPosition: "ABOVE",
      colorScheme: "RAINFOREST",
      height: "MEDIUM",
      xAxisStyle: "STANDARD",
      yAxisStyle: "STANDARD"
    )
  }
)

I am getting No Data available on the chart when I am using "worktype" column , however for "site" column I am getting data

    stefanhelzle0001
    Brainy
    May 17, 2023 6:20 AM UTC

    Try to use synced records. If that's not an option, use a view. The reason is, that loading data into memory for further aggregation is always a risk to performance, stability and hidden bugs.

    16 replies

    stefanhelzle0001
    Brainy
    May 16, 2023 11:16 AM UTC

    Can you share the data returned by that expression?

    Known Participant
    May 16, 2023 11:34 AM UTC

    stefanhelzle0001
    Brainy
    May 16, 2023 11:51 AM UTC

    Well ... worktype does not seem to be a number.

    Please explain what you expect so we can make suggestions of how to change the expression.