Get Aggregated Data Out of Visier

Learn how to perform an aggregate query using the Data Model API and Data Query API.

Introduction

The Data Model API and Data Query API provide you with the ability to discover and inspect the data model objects within your solution and perform aggregation and list queries to retrieve data from Visier.

In this tutorial, you will learn how to retrieve information out of Visier in an aggregate form. We will first walk you through how to navigate the Data Model API to find the required information to perform an aggregate query using the Data Query API, and then show you how to form an aggregate query.

To demonstrate we'll take you through a hypothetical scenario where we use the Data Model API and Data Query API to answer a business question.

You will learn how to:

  • Call the Data Model API to retrieve available objects
  • Perform an aggregate query

Prerequisites

Before beginning this tutorial, you will need:

Scenario

We've been presented with a business goal to achieve 40% representation of women in managerial positions in our organization by 2023. Before we start planning, we need to understand the current representation of women managers.

Steps

Determine what information we want

To get started, let's determine what information we want to get from our Visier solution based on our business goal or question. This will help us narrow down which object types we need to retrieve from the data model and what specific IDs we need to gather for our query.

Knowing our goal is to understand the current representation of women managers in our organization, we want to retrieve the follow object information:

  • A metric that will show us how many employees we currently have
  • A dimension that will group our results by gender so we can compare how many women managers we have to other groups
  • A selection concept that will filter the employee population to managers

Request and retrieve metric objects

Let's send our first request to retrieve the list of all metrics to find the relevant metric that measures how many active employees we have.

GET https://{vanity_name}.api.visier.io/v1/data/model/metrics

In each request in this tutorial we will replace the {vanity_name} with our tenant name jupiter and include the API key and security token as a header.

Copy
cURL sample request: Retrieve a list of metrics
curl -X GET --url 'https://jupiter.api.visier.io/v1/data/model/metrics' \
-H 'apikey:12345'
-H 'Cookie:VisierASIDToken=abc123'

The response will return a list of all metrics which includes the following fields:

Field

Description

id

The unique ID of the metric.

displayName

The localized display name of the metric.

description

The localized description of the metric.

dataStartDate

The date from which data becomes available for this metric.

dataEndDate

The date from which data is no longer available for this metric.

Format for the data start and end date is the number of milliseconds since midnight 01 January, 1970 UTC as a string.

Note: Epochs are expressed as 64-bit integers and represented as stringified longs in JSON due to JSON's inherent limitation in representing large numbers.

analyticObject

The unique ID of the analytic object.

Copy
Sample response: A list of all the metrics in Visier
{
    "metrics": [
        {
            "id": "employeeCount",
            "displayName": "Headcount",
            "description": "The number of employees in the organization.",
            "dataStartDate": "1522627200000",
            "dataEndDate": "1604102400000",
            "analyticObject": "Employee"
        },
        {
            "id": "employeeTenureAverage",
            "displayName": "Tenure",
            "description": "The time in years that employees have worked for the organization.",
            "dataStartDate": "1522627200000",
            "dataEndDate": "1604102400000",
            "analyticObject": "Employee"
        },
        {
            "id": "exitAverageTenure",
            "displayName": "Employee Exit Average Tenure",
            "description": "The average tenure, in years, of employees who exited the organization during the period.",
            "dataStartDate": "1514764800000",
            "dataEndDate": "1622419200001",
            "analyticObject": "Employee_Exit"
        }
    ]
}

By looking through the list of metrics, we find a metric with a description that matches what we want to measure, “the number of employees in our organization”.

Line 4 shows that the ID for the metric is employeeCount, the display name is Headcount, and the metric is based on the analytic object Employee.

Now that we have this information, we need to copy it since it will be used to make additional requests to the data model, as well as in our query. Let's copy the metric ID employeeCount as well as the analytic object Employee.

Request and retrieve dimension objects

Next, we want to find out which dimensions we can group our employees by, specifically gender. We would use this request:

GET https://{vanity_name}.api.visier.io/v1/data/model/analytic-objects/{analyticObjectId}/dimensions

To retrieve this information our request needs to specify the analytic object we want to retrieve dimensions for, in this case Employee.

GET https://jupiter.api.visier.io/v1/data/model/analytic-objects/Employee/dimensions

The response will return a list of all employee dimensions which includes the following fields:

Field

Description

id

The unique ID of the dimension.

displayName

The localized display name of the dimension.

description

The localized description of the dimension.

levels

The levels defined for the dimension.

Levels are the hierarchical structure of members within a dimension. Each level has a unique ID and depth. The depth indicates the level's distance from the top-most level which is always at depth 0.

Copy
Sample response: A list of all dimensions for the Employee analytic object
{
    "dimensions": [
        {
            "id": "Pay_Level",
            "displayName": "Job Pay Level",
            "description": "The pay level or pay grade of the specified job."
        },
        {
            "id": "Performance_Rating",
            "displayName": "Performance Rating",
            "description": "The last performance evaluation of this person."
        },
        {
            "id": "Gender",
            "displayName": "Gender",
            "description": "The gender that the employee identifies with (e.g., woman, man, non-binary).",
            "levels": [
                {
                    "id": "(All)",
                    "displayName": "Level 0"
                    "depth": 0
                },
                {
                    "id": "Gender",
                    "displayName": "Gender",
                    "depth": 1
                }
        }
    ]
}

Looking through the list of dimensions and their descriptions, we were able to find a dimension that groups our employees by gender. Line 14 shows that the ID and display name for the dimension is Gender, and that the dimension has levels associated with it.

The (All) level ID is a summary level and the Gender level ID will include values for each gender. Since we want to retrieve values for each gender we will be using the Gender level ID in our query.

Let's copy the dimension ID Gender as well as the level ID Gender as we will be using these in our query.

Request and retrieve selection concept objects

Next, we need to retrieve available selection concepts to see if we have one that filters employee data by managers.

GET https://{vanity_name}.api.visier.io/v1/data/model/analytic-objects/{analyticObjectId}/selection-concepts

This request will be very similar to the last where we need to include the analytic object we want to retrieve selection concepts for which is Employee.

GET https://jupiter.api.visier.io/v1/data/model/analytic-objects/Employee/selection-concepts

Copy
Sample response: A list of all selection concepts for the Employee analytic object.
{
    "selectionConcepts": [
        {
            "id": "isManager",
            "displayName": "Manager",
            "description": "An employee who is a manager."
        },
        {
            "id": "isMale",
            "displayName": "Male",
            "description": "A person whose gender is male."
        },
        {
            "id": "isTopTalent",
            "displayName": "Top Talent",
            "description": "Employees identified as top talent."
        }
    ]
}

After looking through the list of selection concepts, we were able to find a selection concept that filters employee data by managers. Line 4 shows that the ID for the selection concept is isManager. Let's copy the selection concept ID to use in our query.

Form the aggregate query

Now that we've gathered the required information from the data model, we can perform an aggregation query that shows us how many women employees we have compared to other genders, and how many of those employees are managers.

We will include the following IDs in the body of our query:

  • Metric ID: employeeCount
  • Dimension ID: Gender
  • Dimension level ID: Gender
  • Selection concept ID: isManager
  • Analytic object ID: Employee

When forming our query we also need to specify the time interval. In order to understand the current representation of female managers, we've determined it would be helpful to look at the trend for the past 6 months.

Our request will specify the following:

  • intervalPeriodType, this will be set to MONTH.
  • intervalCount, this will be set to 6 to retrieve values for 6 months.
  • fromDateTime, this will be set to the current date, 2021-01-01

Keep this is mind when working with the time interval:

  • The default TimeDirection is backwards which means the data in the response will move backwards from the specified fromDateTime.
  • The fromDateTime is exclusive. In the below request, the fromDateTime is set at January 1, 2021 to retrieve values up to and including the last day of December.

Explore the aggregate response

You can define the response as JSON or CSV. The default response format is JSON, however since we are retrieving multiple data points, let's use the Accept header value text/csv.

The response will return six months of manager headcount values by gender up to January 1, 2021 in an easy to read format.

Copy

Text/CSV sample response: The aggregated values for employeeCount filtered by isManager and grouped by Gender for the last 6 months up to January 1, 2021.

Measures,DateInRange,Gender
56.0,2020-08-01T00:00:00.000Z,
146.0,2020-08-01T00:00:00.000Z,Female
151.0,2020-09-01T00:00:00.000Z,Male
150.0,2020-09-01T00:00:00.000Z,Female
150.0,2020-10-01T00:00:00.000Z,Male
157.0,2020-12-01T00:00:00.000Z,Male
155.0,2020-11-01T00:00:00.000Z,Male
59.0,2021-01-01T00:00:00.000Z,
60.0,2020-11-01T00:00:00.000Z,
63.0,2020-12-01T00:00:00.000Z,
150.0,2021-01-01T00:00:00.000Z,Female
149.0,2020-10-01T00:00:00.000Z,Female
58.0,2020-10-01T00:00:00.000Z,
147.0,2020-12-01T00:00:00.000Z,Female
148.0,2020-11-01T00:00:00.000Z,Female
154.0,2021-01-01T00:00:00.000Z,Male
156.0,2020-08-01T00:00:00.000Z,Male
56.0,2020-09-01T00:00:00.000Z,

Now you know how to navigate the Data Model API in order to find the required information to perform an aggregate query using the Data Query API.

As a result of our query we were able to get aggregated values that showed us six months of manager headcount data and its distribution among different genders for our organization. We can take this information and use it when planning how many hires we need by when in order to reach our goal.

Next, take a look at this tutorial that shows you how to Get a List of Records Out of Visier.

Resources