Skip to main content

DB_Table.cross_tab

cross_tabgroup_bynamesvalueson_problems

Group: Calculations
Aliases: pivot, unpivot

Documentation

Returns a new table using a chosen field as the column header and then aggregating the rows within each value as specified. Optionally, a set of fields can be used to group the rows.

Arguments

  • group_by: Set of fields to group by. If not provided, a single row will be produced.
  • name_column: The field to use as the column header. If this field is not found, then each value will be a single column.
  • values: The aggregation to perform on each set of rows. Can be a single aggregation or a vector of aggregations. Expressions can be used within the aggregation to perform more complicated calculations.
  • on_problems: Specifies how to handle problems if they occur, reporting them as warnings by default.

Examples

Cross Tab Operation

Input Table table:

     Id | B       | C
----|---------|---------
A | Name | Example
A | Country | France

Result table.cross_tab ['Id'] 'B' (Aggregate_Column.First 'C'):

     Id | Name    | Country
----|---------|---------
A | Example | France

Errors

  • If a column in group_by or name_column is not in the input table, a Missing_Input_Columns is raised as a dataflow error.
  • If a column selector in values given as a Text and it does not match any columns in the input table nor is it a valid expression, an Invalid_Aggregate_Column dataflow error is raised.
  • If a column name generated from the input data is invalid, Invalid_Column_Names error is raised.
  • If an aggregation fails, an Invalid_Aggregation dataflow error is raised.
  • Additionally, the following problems may be reported according to the on_problems setting:
    • If grouping on, using as the column name, or computing the Mode on a floating point number, a Floating_Point_Equality.
    • If when concatenating values there is an quoted delimited, an Unquoted_Delimiter
    • If there are more than 10 issues with a single column, an Additional_Warnings.