DISTINCTCOUNTX
The DISTINCTCOUNTX function in Infoveave calculates the number of unique, distinct values in a column, while considering a specific condition or criteria.
Applicable to
- Calculated Columns
- Expressions
Return Value
- The return value of the DISTINCTCOUNTX function is an integer representing the count of unique, non-duplicate values in the specified column that satisfy the specified condition.
Remark
- DISTINCTCOUNTX is useful when you want to count the number of distinct items in a column or dataset while applying a specific condition or filter. It helps you find out how many unique items meet certain criteria.
- DISTINCTCOUNTX function can be used across Date, Strings and Numbers.
- DISTINCTCOUNTX function takes only all values into account.
Syntax
DISTINCTCOUNTX(<expression>,<condition>)
DISTINCTCOUNTX in Board Expression
Parameter | Description |
---|---|
Expression | A placeholder in a function that is replaced with the actual widget and measure names. |
Condition | A placeholder in a function that is replaced with the condition filter. |
Widget Name | The specific name or identifier of the widget being used for data visualization in the specific Infoboard. |
Measure | Represents the name of the measure that is being displayed or analyzed using the widget. |
Dimension | Represents the dimension column that is being displayed or analyzed using the widget. |
Dimension Value | Represents the specific dimension items within the dimension column used for the visualization in the widget. |
Steps to Use DISTINCTCOUNTX
- Write the DISTINCTCOUNTX function. For instance
DISTINCTCOUNTX(<expression>,<condition>)
- Replace
<expression>
with'Widget Name'[Measure]
and<condition>
with[Dimension Name]="Dimension Value"
. Replace Widget Name, Measure, Dimension, and Dimension Value with your actual values. - Set the DISTINCTCOUNTX function based on the scenario.
- To learn how to configure an Expression in Infoveave, visit the section Configure Expression.
Scenario You’re managing a dataset and an associated Infoboard named ‘Energy Feed,’ which tracks energy customer data, within your Energy Consumption Analysis System. Your goal is to precisely count the number of unique solar customers who qualify for either the “Pay on Time” or “No Discount” categories, without counting any customer more than once. This is vital for understanding customer segmentation and ensuring accurate data analysis.
Scenario Details
- Dashboard Name Energy Consumption Dashboard
- Widget Name Power Feed In
- Measure Name Customers (representing the number of customers)
- Dimension Name Discount Types (categorizing customers based on their payment behavior)
- Dimension Values “Pay on Time” (customers who pay their bills on time) and “No Discount” (customers not eligible for any discount)
Objective Your objective is to count the number of unique customers who belong to either the “Pay on Time” or “No Discount” category. If this count equals 0, you want to trigger a specific action on your dashboard.
- You can use the DISTINCTCOUNTX function like this
DISTINCTCOUNTX('Power Feed In'[Customers], [Discount Types] = "Pay on Time" AND [Discount Types]="No Discount")=0
DISTINCTCOUNTX in Calculated Columns
Parameter | Description |
---|---|
Expression | A placeholder in a function that is replaced with the column names. |
Condition | A placeholder in a function that is replaced with the condition filter. |
Column Name | The name of the column in the dataset or Datasource that contains the values you want to analyze. |
Filter Condition | A filter condition returns the data points that meet the defined condition that you want to analyze. The filter condition can be either a string or a numeric. |
Steps to Use DISTINCTCOUNTX in Calculated Columns
- Write the DISTINCTCOUNTX function. For instance
DISTINCTCOUNTX(<expression>,<condition>)
- Replace
<expression>
with[Column Name]
and<condition>
with[Column Name]="Filter Condition"
. Replace Column Name and Filter Condition with your actual values. - To learn how to add calculated columns in Infoveave, visit the section Calculated Columns.
Objective Consider that you have the below sales dataset, your goal is to count the distinct number of rows in the dataset where COUNTRY is BRAZIL and CATEGORY is BABY FOOD.
ORDER DATE | COUNTRY | CATEGORY | UNIT PRICE | MARKET PRICE | QUANTITY |
---|---|---|---|---|---|
2024-01-03 | Brazil | Baby Food | 38.41 | 43.7874 | 2 |
2024-01-07 | Japan | Spices | 45.56 | 50.8155 | 20 |
Japan | 43.7874 | 10 | |||
2024-01-18 | 32.3019 | 4 | |||
2024-01-22 | Brazil | Cosmetics | 28.335 | 23.0109 | 7 |
2024-01-26 | Canada | 20.185 | 23.0109 | 9 | |
2024-01-04 | France | Cereal | 25.26 | 28.7964 | 9 |
2024-01-09 | Brazil | Cereal | 44.575 | 50.8155 | 8 |
2024-01-14 | Brazil | Snacks | 20.185 | 4 | |
Brazil | Cosmetics | 40.485 | 46.1529 | 2 |
You can use the DISTINCTCOUNTX function like this
DISTINCTCOUNTX([COUNTRY],[COUNTRY]="Brazil" AND [CATEGORY]="Baby Food")
The new calculated column will return the total number of rows that met the condition as 1.
ORDER DATE | COUNTRY | CATEGORY | UNIT PRICE | MARKET PRICE | QUANTITY | COUNTRY COUNT |
---|---|---|---|---|---|---|
03-01-2024 | Brazil | Baby Food | 38.41 | 43.7874 | 2 | 1 |
07-01-2024 | Japan | Spices | 45.56 | 50.8155 | 20 | 1 |
Japan | 43.7874 | 10 | 1 | |||
18-01-2024 | 32.3019 | 4 | 1 | |||
22-01-2024 | Brazil | Cosmetics | 28.335 | 23.0109 | 7 | 1 |
26-01-2024 | Canada | 20.185 | 23.0109 | 9 | 1 | |
04-01-2024 | France | Cereal | 25.26 | 28.7964 | 9 | 1 |
09-01-2024 | Brazil | Cereal | 44.575 | 50.8155 | 8 | 1 |
14-01-2024 | Brazil | Snacks | 20.185 | 4 | 1 | |
Brazil | Cosmetics | 40.485 | 46.1529 | 2 | 1 |