Page tree

This is the documentation for ConfiForms Server/Data Center app

However, this might also work for ConfiForms cloud and in most cases it does. But please see this page to understand the differences between server and cloud versions of the ConfiForms app.



With TableViewMerger macro you can do data aggregations and merging. We can supply the sources for the data to be supplied from different sources / forms.

There is a number of tutorials available on this topic already


In this cookbook we show how you can quickly group the data by "key" and count how many times the row with this "key" is present in the dataset

Consider to have a simple form with a given structure (2 fields):

<ac:structured-macro ac:macro-id="f73aa705-b8a4-4cc2-90a6-a41ad564a6a9" ac:name="confiform" ac:schema-version="1">
  <ac:parameter ac:name="formName">f</ac:parameter>
  <ac:rich-text-body>
    <ac:structured-macro ac:macro-id="7f0d488e-a2a7-4139-87c6-75747865375e" ac:name="confiform-entry-register" ac:schema-version="1">
      <ac:rich-text-body>
        <p>
          <br/>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p>
      <ac:structured-macro ac:macro-id="c2f4c073-8a47-4827-bdc5-8ff6698602b4" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">name</ac:parameter>
        <ac:parameter ac:name="fieldLabel">User name</ac:parameter>
        <ac:parameter ac:name="type">text</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="b2c5bde3-6078-4940-87eb-e08dd75b0d4a" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">age</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Age</ac:parameter>
        <ac:parameter ac:name="type">number</ac:parameter>
      </ac:structured-macro>
    </p>
  </ac:rich-text-body>
</ac:structured-macro>

And we need to count how many times in the records the field name has occurred

We will use TableViewMerger to help us with this sort of calculation

And the configuration would be as follows:

Code:

<ac:structured-macro ac:macro-id="12e6adff-88dd-44f5-8b56-1267299595f3" ac:name="confiform-table-merger" ac:schema-version="1">
  <ac:rich-text-body>
    <p>
      <ac:structured-macro ac:macro-id="accce381-7fc1-44b8-b716-9be2533d2ca6" ac:name="confiform-field" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">name</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="053919d7-7cf9-4f12-9c74-bb054cadca56" ac:name="confiform-field" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">How many times:([count])</ac:parameter>
      </ac:structured-macro>
    </p>
    <ac:structured-macro ac:macro-id="d388ac17-e047-42b5-8055-888ffa427e05" ac:name="confiform-table" ac:schema-version="1">
      <ac:parameter ac:name="formName">f</ac:parameter>
      <ac:rich-text-body>
        <p>
          <br/>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
  </ac:rich-text-body>
</ac:structured-macro>

Important bits here are:

  • We specify a ConfiForms Field macro with field name set to "name" to point at our "name" fields in the form. This is not an expression (does not have a wrapping () around it's name and doe s not have a reference to [entry.field_name], so it will be taken as grouping key!)
  • For the second column, to count, we define an expression like

    How many times:([count])

    It defines a label to be used (How many times) and the expression to calculate ([count]). You can use Supported math operators, formulas and functions and you can have references to filed values in expressions via [entry.field_name] notations

  • [count] and [total] are special context variables available in TableViewMerger. [count] shows the records count for a grouped by key, while [total] holds a total number of records in the dataset


So, for the data like this:

you will get this calculated with TableViewMerger like this:


User name

How many times

sash 2
vlad 1

You can put the generated table (whole TableViewMerger macro configuration) into a chart macro to build nice charts and graphs over your data. Consult Atlassian documentation on how to use the chart macro: https://confluence.atlassian.com/doc/chart-macro-163415075.html


Bonus:

To illustrate how to count registrations by user name, in other workds by metafield "createdBy"

You will need to configure your TableViewMerger macro like this

What if you want to count the records, but have multiple fields as a grouping key?

The concept is the same. Fields without expressions are taken in to form a unique key for the record. Let's say we want to group the records by createdBy and our "name" field

The configuration for TableViewMerger will be then 


Sometimes you dont need a field value that forms a grouping key to be presnet in the resulting table. This is possible by configuring the field not to display


So the resulting table with configuration like this

will have 2 columns in teh result, not 3 as defined in the configuration (because one is set to be hidden)


User name

How many times

sash 2
vlad 1