Skip to end of metadata
Go to start of metadata

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

Compare with Current View Page History

« Previous Version 3 Next »

Introduction

Counting values is very useful and there is functionality within PhixFlow to help us achieve this.


Simple Count

We can generate counts of particular attributes using a View. This means we do not need to edit the source data only how is is displayed.

Example

We have a set of company details and we want to see how many time a company name appears in the list. 

Solution

  1. Open the properties of the table holding the company data.
  2. Create a new view
    1. Set the Name e.g. Company Counter.
    2. Set the Display Type to Grid.
    3. Sort order and Filters are Optional for our example. See View for more details.
    4. In View Attributes click  Show or Hide Attributes
    5. From the popup box that appears, drag in the name of the company into the View Attributes section:
    6. Double click this View Attribute to open its properties.
      1. Change the Name to Count or something useful. It must be changed.
      2. Set Aggregate Function to Count.
      3. Save all your changes.
      4. This will produce a count based on the other attributes in the view.
    7. Now add the name of the company to the view. 
  3. Save all your changes
  4. In the Table right-click the view we just created  and select View Chart. A view of the data will display a count of all the companies.

There are other useful Aggregate Functions available that we can use to generate other metrics n our view, see View Attribute for more detail on these.


Bespoke Counts

Where we need to generate more complex counts such as the total sum of invoices by year, we need to create additional attributes to hold the information that will be aggregated on.

Example

If we have invoice information:

From this information we would like to generate the sum of all invoices by year

Solution

  1. Create a new attribute on the table containing the Invoice information.
    1. Name the attribute Year.
    2. Set Type to Integer.
    3. Set the expression to:
      1. dateGet(_out.InvoiceDate, _YEAR)
      2. This statement will extract a year from a date attribute, see dateGet.
    4. Save your changes.
  2. Rerun Analysis on your Table and the new attribute will be populated.
  3. Create a new View on your table
    1. Set Name to Invoice by Year or something suitable.
    2. Set Display Type to Grid.
    3. In View Attributes click  Show or Hide Attributes
    4. Add in the attribute that contains the invoice amount and the new Year attribute.
      1. Double click the Amount attribute to open its properties and set the Aggregate Function to Sum.
      2. This will sum all the amounts by year.
    5. Save your changes.
  4. In the Table right-click the view we just created  and select View Chart.


It can often be useful to add a new integer attribute with the value 1 to all records coming in, this  facilitates the ability to quickly get sum totals based on other fields. For example the number of invoices by year or number of people with the surname "Smith".


More Information

For more information on presenting counts and stats see Understanding Data Views.

  • No labels