COUNT_DISTINCT

View as Markdown

Syntax fragment: COUNT_DISTINCT(<table>.<column>, <start>, <end>, <unit>)

Description

Calculates the cardinality/count of distinct values in the specified <table>.<column> column starting from <start> days to <end> days. When used in the target field, the time period should be positive (in the future). When used in a temporal filter field, the time period should be negative (in the past).

This operator can be applied to columns of any type.

Example

PQL
COUNT_DISTINCT(orders.merchant_id, 0, 30, days)

In-context Example Considerations

  • KumoRFM evaluates the query over historical slices and eligible entities to construct in-context examples.
  • If for a given entity and historic data slice there are no fact rows to aggregate over, the training example label is set to the value 0.
  • For all aggregations, the start time is excluded from the calculation and the end time is included in the calculation.
  • The units for the start and end times is days by default but can be specified as months or hours.