Skip to main content
This gem runs in .
Use the Tile gem to assign records to tiles based on your data and the tiling method you choose. You can distribute records by equal sum, equal record count, standard deviation bands, unique values, or manually defined cutoffs. The gem appends tile information to your data so you can analyze ranges, sequence within each tile, and grouped distributions. Depending on the method, you can also group records first or control how rows are ordered before tiles are assigned.

Prerequisites

Add prophecy_basics package version 1.0.11 or higher to your project.

Overview

The Tile gem supports these tiling methods:
  • Equal Sum
  • Equal Records
  • Smart Tile
  • Unique Value
  • Manual
The output appends two fields to the data:
  • Tile number, which stores the tile assigned to the record
  • Tile sequence number, which stores the record’s position within the tile

Parameters

ParameterDescription
Select tiling methodChoose the tiling method. Available options are Equal Sum, Equal Records, Smart Tile, Unique Value, and Manual.

Equal Sum

Use Equal Sum to assign tiles so each tile has approximately the same total from the selected sum field based on the row order.

Parameters

ParameterDescription
Number of TilesSpecify how many tiles to assign.
Select Sum ColumnSelect the numeric field used to distribute totals across tiles.
Select ColumnSelect the column used for tiling configuration.
Select group by columns (Optional)Optionally select fields to create tiles independently within each group.
Order rows within each group (Optional)Optionally order rows before assigning tiles. This section includes Order By Columns and Sort strategy.

Order rows within each group

Use Order By Columns to select the columns used to order rows. Use Sort strategy to choose one of the following options:
  • ascending nulls first
  • ascending nulls last
  • descending nulls first
  • descending nulls last

Example

Let’s say you have the following dataset and set Number of Tiles to 2.
RecordSales
A10
B20
C15
D15
If you select Equal Sum and use Sales as the sum column, the gem assigns records so each tile has a similar total based on the row order.

Result

RecordSalesTile numberTile sequence number
A1011
B2012
C1521
D1522
In this example, both tiles total 30.

Equal Records

Use Equal Records to divide input records into the specified number of tiles so each tile contains the same number of records as closely as possible.

Parameters

ParameterDescription
Number of TilesSpecify how many tiles to assign.
Select group by columns (Optional)Optionally select fields to create tiles independently within each group.
Do not split tile on Columns (Optional)Optionally prevent a tile from splitting across the selected column.
Order rows within each group (Optional)Optionally order rows before assigning tiles.

Example

Let’s say you have the following dataset and set Number of Tiles to 2.
RecordScore
A90
B85
C80
D75
If you select Equal Records, the gem divides the four records into two tiles with two records in each tile.

Result

RecordScoreTile numberTile sequence number
A9011
B8512
C8021
D7522

Smart Tile

Use Smart Tile to create tiles based on the standard deviation of values in a numeric field. The assigned tile indicates whether the value falls within the average range, above the average, or below the average.

Parameters

ParameterDescription
Select Tile Numeric ColumnSelect the numeric field used for the tile calculation.
Select ColumnSelect the column used for tiling configuration.
Select group by columns (Optional)Optionally select fields to create tiles independently within each group.
Do not output name columnDo not append a descriptive name column.
Output name columnAppend a descriptive output field. Descriptors include Average, Above Average, High, Extremely High, Below Average, Low, and Extremely Low.
Output verbose name columnAppend a descriptive output field and include the value range in parentheses.

Example

Let’s say you use Price as the tile numeric column and enable Output name column.
Sale_IDPriceTile numberSmartTile_NumTile sequence number
211.89-1Below Average1
1215.16-1Below Average2
418.06-1Below Average3
2719.91-1Below Average4
In this example, the records fall into the -1 band and the output includes the descriptive label Below Average.

Unique Value

Use Unique Value to assign a unique tile to each unique value in one or more selected fields. If you select multiple fields, the tile is based on the combination of values.

Parameters

ParameterDescription
Select Unique ColumnSelect one or more fields used to assign unique tiles.
Select group by columns (Optional)Optionally select fields to create tiles independently within each group.

Example

Let’s say you have the following dataset and select Category as the unique column.
RecordCategory
ABooks
BGames
CBooks
DMusic
If you select Unique Value, each unique category receives its own tile.

Result

RecordCategoryTile numberTile sequence number
ABooks11
CBooks12
BGames21
DMusic31

Manual

Use Manual to define tile cutoffs yourself.

Parameters

ParameterDescription
Select Tile Numeric ColumnSelect the numeric field used for tile assignment.
Enter one or more tile cutoffsEnter each tile’s upper limit separated by commas.

Example

Let’s say you have the following dataset, select Score as the tile numeric column, and enter the cutoffs 50,80.
RecordScore
A30
B60
C90
If you select Manual, the gem assigns tiles based on the cutoffs you provide.

Result

RecordScoreTile numberTile sequence number
A3011
B6021
C9031