How do I automatically construct a filter URL for passing through fields to a dashboard

Omni’s filter URL structure is built off of JSON. Because of this, we can use a JSON structure to create the filter parameters in the URL, which are later encoded and passed through to link to a dashboard in Omni.

Depending on the type of filter, there will be different expectations for the arguments.

In Omni, we have the following types of filters:

  • string = 'string'
  • number = 'number'
  • date = 'date'
  • boolean = 'boolean'
  • null = 'null'

Each filter has its own set of parameters that it takes in as JSON, and is then stringified and incorporated to a URL via the filter search parameters.

String filters

String filter parameters and data type expectations: {kind: string, values: string[], is_negative: boolean, case_insensitive: boolean, hidden?: boolean}

kind: indicates the type of string filter being enacted, possible values are:

  • is equal to
  • contains
  • starts with
  • ends with
  • is empty

values: can be passed as an array of strings which are dependent on user input.

is_negative: determines if a filter is modified by a negative input or not. For example, a contains filter with is_negative set to true will act as “does not contain”.

case_insensitive: determines if the filter is case sensitive or not to the results. Case insensitive with true, case sensitive with false

hidden?: determines if the filter is hidden or not. Hidden with true, visible with false

Date filters

Date filter parameters and data type expectations: {kind: DATE_FILTER_KIND, left_side?: string, right_side?: string, is_negative: boolean, ui_type?: DATE_FILTER_UI_TYPE, isFiscal: boolean, hidden?: boolean}

kind:

  • IS_ON_DAY_OF_WEEK = ‘IS_ON_DAY_OF_WEEK’,
  • IS_ON_DAY_OF_QUARTER = ‘IS_ON_DAY_OF_QUARTER’,
  • IS_IN_MONTH_OF_YEAR = ‘IS_IN_MONTH_OF_YEAR’,
  • IS_ON_DAY_OF_YEAR = ‘IS_ON_DAY_OF_YEAR’,
  • IS_AT_HOUR_OF_DAY = ‘IS_AT_HOUR_OF_DAY’,
  • IS_IN_QUARTER_OF_YEAR = ‘IS_IN_QUARTER_OF_YEAR’,
  • IS_ON_DAY_OF_MONTH = ‘IS_ON_DAY_OF_MONTH’,
  • BETWEEN = ‘BETWEEN’,
  • ON_OR_AFTER = ‘ON_OR_AFTER’,
  • BEFORE = ‘BEFORE’,
  • TIME_FOR_INTERVAL_DURATION = ‘TIME_FOR_INTERVAL_DURATION’,
  • TIME_FOR_UNIT_DURATION = ‘TIME_FOR_UNIT_DURATION’

left_side?: this is the value that is passed into the left side of a date filter. For a between kind, this would be the starting date in the range. For TIME_FOR_INTERVAL_DURATION or ON_OR_AFTER it would be the starting point in time. For IS_ON_DAY_OF_WEEK, it would be the day of week.

right_side?: this is the value that is passed into the right side of a date filter. For a between kind, this would be the ending date in the range. For TIME_FOR_INTERVAL_DURATION, it would be the length of time. For IS_ON_DAY_OF_WEEK or ON_OR_AFTER, it would be null.

is_negative: determines if a filter is modified by a negative input or not. For example, a contains filter with is_negative set to true will act as “does not contain”.

ui_type?: This is to set the UI for the user of what will be shown in the filter. Because a single result can be achieved multiple ways, this allows for a certain control to be set on the UI side of what is shown to the user for a given filter. Not required, if not used we will make our best guess of what we show though the underlying logic will be dictated by the “kind” and “left_side?” and “right_side?” values. The possible values for a UI_TYPE are:

  • ANY_TIME = ‘ANY_TIME’,
  • BEFORE = ‘BEFORE’,
  • BETWEEN = ‘BETWEEN’,
  • MONTH_OF_YEAR = ‘MONTH_OF_YEAR’,
  • PAST = ‘PAST’,
  • YEAR = ‘YEAR’,
  • DAY = ‘DAY’,
  • DAY_OF_WEEK = ‘IS_ON_DAY_OF_WEEK’,
  • ON_OR_AFTER = ‘ON_OR_AFTER’,
  • IS_IN_THE_MONTH = ‘IS_IN_THE_MONTH’,
  • IS_IN_THE_QUARTER = ‘IS_IN_THE_QUARTER’,
  • IS_IN_THE_FISCAL_QUARTER = ‘IS_IN_THE_FISCAL_QUARTER’,
  • IS_IN_THE_FISCAL_YEAR = ‘IS_IN_THE_FISCAL_YEAR’,
  • TIME_FOR_INTERVAL_DURATION = ‘TIME_FOR_INTERVAL_DURATION’,
  • TIME_FOR_UNIT_DURATION = ‘TIME_FOR_UNIT_DURATION’,
  • CUSTOM = ‘CUSTOM’,

is_fiscal: determines if the date filter operates over a fiscal period. If true, the fiscal offset specified in the model is used, otherwise if false it is not used.

hidden?: determines if the filter is hidden or not. Hidden with true, visible with false

Numeric Filters

Numeric filter parameters and data type expectations: {kind: NUMERIC_FILTER_KIND, values: string[], is_negative: boolean, is_inclusive: boolean, hidden?: boolean}

kind:

  • LESS_THAN = ‘LESS_THAN’,
  • GREATER_THAN = ‘GREATER_THAN’,
  • EQUALS = ‘EQUALS’,
  • BETWEEN = ‘BETWEEN’

values: string array of inputs to be filtered on

is_negative: determines if a filter is modified by a negative input or not. For example, a contains filter with is_negative set to true will act as “does not contain”.

is_inclusive: determines if the filter is inclusive or not on the kind. inclusive with true, not inclusive with false

hidden?: determines if the filter is hidden or not. Hidden with true, visible with false

Boolean Filters

Boolean filter parameters and data type expectations: {is_negative: boolean | null, treat_nulls_as_false?: boolean, hidden?: boolean}

is_negative: determines if a filter is modified by a negative input or not. For example, a contains filter with is_negative set to true will act as “does not contain”.

treat_nulls_as_false: determines if the filter treats null values as false or not. Does include and treat as false if the value is true, does not include if the value is false

hidden?: determines if the filter is hidden or not. Hidden with true, visible with false

Null Filter

Null filters are used whenever an “Is Null” filter criteria is selected, allowing this to be swapped in.

Null filter parameters and data type expectations: {is_negative?: boolean, hidden?: boolean}

is_negative: determines if a filter is modified by a negative input or not. For example, a contains filter with is_negative set to true will act as “does not contain”.

hidden?: determines if the filter is hidden or not. Hidden with true, visible with false