Child pages
  • TableViewMerger macro to help us to count registrations by user

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

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:


  • No labels