The Crosstab Tab
Crosstab is a pivot table feature that arranges categorical variables in rows and columns for aggregation.
Basic Usage
Opening Crosstab
Select Analysis > Crosstab Analysis... from the menu bar to open a new Crosstab tab.
Creating a Cross Tabulation
Specify fields in the settings panel on the left.
Rows: Select categorical variables to place in rows. Multiple selections create hierarchical row headers.
Columns: Select categorical variables to place in columns. Multiple selections are also possible.
Values: Select fields and aggregation functions (SUM, AVG, COUNT, MIN, MAX). Only numeric and boolean columns can be added as value fields. A newly added value field uses SUM. Generating with Values left empty creates a frequency table, in which each cell shows the number of rows for its combination of row and column categories. The number counts all rows, including those with missing values, and equals the value of any value field aggregated with COUNT. A frequency table can be created regardless of column types, including from a dataset with only categorical variables.
When configuration is complete, click the Generate Crosstab button.

The column headers of the table show what each value aggregates and how. The headers have two rows: the upper row shows the column categories, and the lower row shows the label of the value field. The label combines the aggregation function and the column name in the form AVG(Sales). The label of COUNT is COUNT(*) regardless of the column. The label of a frequency table without value fields is also COUNT(*).
Changing the fields after generating makes the displayed table no longer belong to the current settings. Restoring the previous settings brings the table back.
Saving Results
Click Save as Dataset to save the cross tabulation's aggregated values as a new dataset. Percentage, sorting, visual mode colors, and the display settings of totals are not saved.
The saved dataset has the row field columns followed by one column for each pair of a column category and a value field. The name of such a column joins the category and the value field label with _. For example, AVG(Sales) for the column category A becomes the column A_AVG(Sales). With multiple column fields, the category part joins the categories of the column fields with /, giving a column name such as North / A_AVG(Sales). When column names coincide, for example for categories that differ only in uppercase and lowercase letters (A to Z) such as a and A, the later column gets a sequential number, such as A_AVG(Sales)_1. A frequency table without value fields has one row-count column for each column category, such as A_COUNT(*).
Click Add to Report to add the cross tabulation to a report. Percentage, visual mode colors, and the display settings of totals are kept, but sorting is not reflected.
Editing Saved Crosstabs
Existing Crosstab datasets can be edited. Right-click a dataset in the Project Lineage tab, or open the dataset menu (⋮) in Project Overview, and select Edit Operation... to open Crosstab in edit mode with the source dataset, row fields, column fields, and value fields restored.
Changing the source dataset carries over the fields whose columns exist in the new source under the same name. Fields whose columns are missing, and value fields whose columns are no longer numeric or boolean, are removed and listed in a notice. Click Generate Crosstab, then Update Dataset to apply the changes. Derived datasets that depend on this dataset are recalculated the next time their data is needed, and dependent models are automatically re-estimated.
If the transformation is changed from another path such as another edit tab or the Agent API between the time this tab opens and the time you click Update Dataset, MIDAS stops the save and shows a dialog. Choose Overwrite with This Tab's Edits to save the edits in this tab over the version changed elsewhere. Choose Keep Editing to return to the edit tab without saving; the edits stay in place.
Aggregation Functions
The following aggregation functions are available for Values fields:
- SUM (total)
- AVG (average)
- COUNT (count)
- MIN (minimum)
- MAX (maximum)
When you place a boolean column as a value field, true is counted as 1 and false as 0, so SUM gives the count of true values and AVG gives the proportion of true values.
Display Options
Showing Totals
Control total display in the Options section.
Turn on Show row totals to display row totals on the right edge.
Turn on Show column totals to display column totals at the bottom.
Turn on Show grand total to display the overall grand total.
For AVG, MIN, and MAX, a total does not re-aggregate the cell values. It reapplies the same aggregation function to all records in that row, column, or the whole table.
Percentage Display
Percentage display can show values as percentages.
- None - Do not display percentages
- Row % - Display percentage of row total. If a cell value is 10 and the row total is 50, Row % is 20%
- Column % - Display percentage of column total. If a cell value is 10 and the column total is 40, Column % is 25%
- Total % - Display percentage of grand total. If a cell value is 10 and the grand total is 200, Total % is 5%
- All - Display Row %, Column %, and Total % at the same time
Row %, Column %, and Total % appear only when Show row totals, Show column totals, and Show grand total are on, respectively.
A cell whose percentage is undefined shows "-" as its percentage. This happens when the cell value or the denominator total is "-", or when the denominator total is 0.
When the values aggregated with SUM mix positive and negative values, percentages can no longer be read as shares of the total. In this case, percentages can fall outside the range from 0% to 100%. When the denominator total is negative, the sign of the percentage is the opposite of the sign of the cell value. When positive and negative values cancel out and the denominator total approaches 0, the absolute value of the percentage becomes extremely large. MIDAS also shows this large value instead of "-" when floating-point rounding error keeps the total from being exactly 0.
Note: Percentage calculation is not available for AVG, MIN, MAX aggregations.
Sorting
Set sorting options in the Display tab.
Row Sorting
- Original Order - Sorts by category value in ascending order, not the input data order. Enum columns follow their definition order, and NULL for missing values comes last
- Label (A-Z) - Sort by label in ascending order
- Label (Z-A) - Sort by label in descending order
- Value - Sort by aggregated value
Column Sorting
Same sorting options as rows are available.
For Value sorting, you can specify which column/row value to use as the basis, and whether ascending (Low to High) or descending (High to Low).
Value sorting places rows and columns whose basis value is "-" last, in both ascending and descending order. When the basis cell has no records, COUNT sorts it as 0, and the other aggregation functions place it last like "-". Missing Values explains "-" and the display of cells without records.
Label sorting uses the first field as the basis, and Value sorting uses the first value field. In a frequency table without value fields, Value sorting uses the row counts and sorts cells without records as 0. You cannot sort by the second or later level in hierarchical rows (multiple row variables) or with multiple value fields.
Visual Mode
Change display style with Visual Mode in the Display tab. Available when there is one value field, and for a frequency table without value fields.
- Table - Display in standard table format
- Heatmap - Express value magnitude with cell background color. Colors are mapped based on the range from the minimum to the maximum value across the cells
- Text + Heatmap - Display numbers and heatmap simultaneously
- Bar in Cell - Display bar charts within cells


Color Scheme
A color scheme can be selected in all visual modes except Table. Heatmap and Text + Heatmap apply it to cell background colors, and Bar in Cell applies it to the bar color.
- Blue - Blue gradient
- Red - Red gradient
- Green - Green gradient
- Diverging (Red-White-Blue) - Gradient from red through white to blue. White represents the median of the cell values
The minimum, maximum, and median used for the color scale exclude row totals, column totals, and the grand total.
Cell Operations
Cell Selection
Clicking a cell selects the original data rows corresponding to that cell. Selected rows are highlighted in other views as well. When you click a cell while holding Ctrl/Cmd, MIDAS removes the cell's rows from the selection if all of them are selected, and adds them to the selection otherwise. The click rules are described in Sharing the Selection.
Drill Down
Double-clicking a cell opens a Filtered Data tab with only the data matching that cell's criteria.

In the Crosstab on the left, double-clicking the "44" cell (Adelie x Biscoe) opens a Filtered Data tab with the 44 rows matching those criteria.
Multiple Value Fields
Adding multiple fields to Values expands each column by value field. For example, if you specify SUM(Sales) and AVG(Profit), two columns appear for each column category, and the lower header row shows SUM(Sales) and AVG(Profit) respectively.
Missing Values
When row or column fields contain missing values, they are aggregated as an independent category labeled NULL. This NULL category is included in row totals, column totals, and the grand total, so it also enters the denominators of Row %, Column %, and Total %. To compute percentages that exclude missing values, filter out NULL beforehand.
When value fields contain missing values, COUNT counts all rows including missing values, while SUM, AVG, MIN, and MAX exclude missing values from calculation. The tooltip of a cell adds the number of values used to each aggregation that excluded missing values.
When every value-field value in a cell or total is missing, SUM, AVG, MIN, and MAX have no numbers to aggregate, so MIDAS displays the value as "-". This value is distinct from 0. In a dataset saved with Save as Dataset, a "-" cell becomes a missing value.
A cell whose combination of row and column categories has no records is displayed as "—", not "-". A "-" cell has records, and all of their value-field values are missing. A "—" cell has no records. In a dataset saved with Save as Dataset, a "—" cell becomes 0 for COUNT and frequency tables, and a missing value for the other aggregation functions.
Also available as a Markdown file.