Home / How-to / Model your data
Define the grain
Decide what one row of your fact stands for, bring your sources together in steps, and tell the fact which columns are measures.
The short version
- A Stepped Definition Grain defines the rows of a fact. Order Lines gives one row per order line.
- It works like a Stepped Transform Prep: one source element, a list of steps, and a live preview of the result.
- Give every column a Mode: Fact for measures, Dimension for columns that join a dimension, Degenerate for plain columns the fact keeps, Debug for columns the fact leaves out.
- A Sample keeps every row for the first N values of one column, so you can work on a small but complete slice. Set it to All before the real run.
- Design mode, the default, stores no table: the elements built on the grain run its steps as part of their own processing.
In this guide
What a grain element is
The grain is what one row of a fact stands for. In a star schema you decide it first, because everything else follows from it. If the idea is new, read Star schema basics first.
In ConradBI the grain is an element of its own, in the Grains group, between Preps and Dimensions. Its type is the Stepped Definition Grain. It reads one source element, runs a list of steps over it, and gives the rows that the fact will hold, one for one.
A grain usually does two jobs:
- It brings the sources together. Orders holds codes, like Site Code. Sites holds the names and regions behind them. The grain joins them, so each order line carries everything about itself.
- It classifies the columns. Each column gets a mode that tells the fact what it is: a measure, a link to a dimension, or a plain column.
The fact reads one grain, and has exactly as many rows. Most dimensions read their columns from the grain too.
Before you start
You need:
- Orders Prep, the Stepped Transform Prep over the Orders acquisition, with its Revenue column (
[Units] * [Unit Price]). See Prepare data with steps. - The Sites, Products and Customers acquisitions, each processed.
- Orders Prep processed once, so the preview has rows to show.
This guide builds Order Lines, one row per order line, with these columns:
| From | Columns |
|---|---|
| Orders Prep | Order ID, Order Date, Ship Date, Site Code, Product Code, Customer ID, Channel, Units, Unit Price, Cost, Discount, Status, Email, Revenue |
| Sites | Site Name, Region |
| Products | Product Name, Category |
| Customers | Customer Name, Segment |
Build Order Lines
This takes about ten minutes.
- In the element list, click the + on the Grains row. In Add element, type
Order Linesin Name and click OK. The new grain opens in the editor. - In Source element, pick Orders Prep. Only acquisitions and preps are offered. The Data tab at the bottom now shows the source's rows.
- Join the site details. In Step Management, pick Join Element from the list and click Add. Set Join element to Sites and Join type to Left. Leave the match on Column mapping, click Add condition, and pick Site Code under Result column and Site Code under Joined element column.
- Add two more Join Element steps the same way: Products on Product Code, and Customers on Customer ID.
- A join adds every column of the joined element at the end, and a name the result already has gets a number: Site Code 2. Add a Remove Columns step and tick Site Code 2, Product Code 2 and Customer ID 2 under Remove.
- Open the Schema tab at the bottom and set each column's Mode: Units, Unit Price, Cost, Discount and Revenue to Fact; Order ID, Channel and Status to Degenerate; Email to Debug. Leave the rest at Dimension.
- Open the Data tab and look over a few rows. The caption above it says which step the preview reaches, for example "Result up to step: Remove Columns".
- Save the grain: ProjectSave, or Ctrl+S.
Order Lines now has one row per order line, and each row carries its site, product and customer details. The fact and the dimensions in the next guides are built on it.
Tip: Use Left joins in a grain. A Left join keeps an order line whose code is missing from Sites, with its site columns blank. An Inner join would drop the line, and its revenue with it.
Column modes
The Mode column of the Schema tab tells the fact what each column is. Every column starts as Dimension.
| Mode | What the fact does with it | In Order Lines |
|---|---|---|
| Fact | Offers it as a measure, to add up | Units, Unit Price, Cost, Discount, Revenue |
| Dimension | Lists it in its Dimensions grid, to join a dimension on | Order Date, Ship Date, Site Code, Site Name, Region, Product Code, Product Name, Category, Customer ID, Customer Name, Segment |
| Degenerate | Keeps it on every row as a plain column, and offers it as a measure too, for a count | Order ID, Channel, Status |
| Debug | Leaves it out |
A few things to know:
- Modes speak only to the fact. A dimension built on the grain can use any of its columns, whatever their mode. Site Name and Region stay Dimension because they describe the site, and the Site dimension is built from them.
- A fact open in another tab follows along. Change a mode and the fact's lists update straight away, before you save.
- Degenerate suits a column with no table of its own, like an order number or a channel. Visuals can group by it directly on the fact.
- Debug keeps a column in the grain's preview while you work, without it reaching the fact.
Steps
A grain has the same steps as a Stepped Transform Prep, and its editor works the same way: Step Management on the left, the Step Designer for the selected step on the right, and the Schema and Data tabs below. Every step, from Join Element to Row Filter and Custom Column, is explained in Prepare data with steps.
The differences in a grain:
- Source element offers only acquisitions and preps, and so do the Join Element and Union steps.
- The Schema tab has the Mode column, and the editor has the Sample settings described next.
Do the cleanup in preps, and keep the grain for bringing sources together and settling the grain. A step that combines rows, such as Group By or Remove Duplicate Rows, changes the grain itself, so say the grain again in one sentence after adding one.
When your data is in SQL Server, the grain's steps run on the server. If a step can't, a Bulk Copy Only button shows at the top right of the editor. Click it to see which steps.
Work on a sample
A large grain is slow to process, and so is everything built on it, while you are still building. A Sample makes the grain keep a small slice that is still complete.
- Next to Sample, pick a size: Top 100, Top 1000, or Top N and type the number in the box beside it.
- In of column, pick the column the sample is based on, for example Customer ID.
With Top 100 and Customer ID, the grain keeps every row of the first 100 different customers: every order line of 100 customers, not 100 order lines picked at random. A customer's history stays whole, so sums and counts per customer stay right. Rows where the column is blank are left out.
Nothing is sampled until a column is picked, and All turns sampling off.
The sample applies when the grain is processed, and so to everything built on it: the fact and the dimensions see only the sampled rows. The editor's own preview isn't sampled.
Tip: Pick All before you build the real thing. A sample left on gives a fact with a fraction of your orders.
The sample is the grain's own. It has nothing to do with any limit on the rows a processing run loads.
Design or Persist
Process Mode at the top of the editor decides whether the grain stores a table of its own.
- Design, the default for a grain: no table is stored. Each element built on the grain runs the grain's steps as part of its own processing. When everything is in SQL Server, the grain's steps and the fact's work become one query on the server.
- Persist: processing stores the grain's rows as a table, and the elements built on it read that table.
Design saves storing a copy of every order line. The cost is that each element built on the grain, the fact and every dimension, runs its steps again. Switch to Persist when the steps are heavy and several elements read the grain, above all when the work can't be done in SQL Server.
How the fact and dimensions use it
A Basic Fact names its grain in Grain element:, at the top of its editor. Only grain elements are offered, and a fact reads exactly one. From there:
- The fact has one row for each row of the grain. Sales has one row per order line.
- Its Dimensions grid lists the grain's Dimension columns, one row each, ready to be matched to a dimension.
- Each measure's Fact column list offers the grain's Fact and Degenerate columns.
- The Degenerate columns are carried onto every row of the fact as they are.
See Facts and measures for the fact itself.
Dimensions read the grain as well. A Changing Dimension is bound to a grain and picks its columns from it, and the junk dimensions take their columns from grains. A Date Dimension can read a date column of a grain to set its range. See Build dimensions and Date dimensions.
When something goes wrong
| What you see | What to do |
|---|---|
| "Bind a source to see its rows here." | Pick a Source element |
| "The source hasn't been processed, so there are no rows to show yet: process it, and they appear here when the run finishes." | Open Orders Prep and click Process current in the Services panel, or click Process all |
| "No rows pass these steps." | A step drops every row, often a Row Filter or an Inner join whose codes don't match. Select the steps one at a time to find it |
| A column is missing from the fact's Dimensions grid | Set its Mode to Dimension |
| A column is missing from a measure's Fact column list | Set its Mode to Fact or Degenerate |
| The fact has far fewer rows than the source | A sample is on. Pick All next to Sample, then process again |
| Columns named Site Code 2 or Region 2 | A join added a column the result already had. Remove the copy with a Remove Columns step |
| The grain has more rows than Orders Prep | A join matched an order line to several rows, because the code isn't unique in the joined element. Remove the repeats there, for example with a Remove Duplicate Rows step in its prep |
| An element isn't offered in Source element | A grain reads only acquisitions and preps |
Reference
| Setting | Where | What it does |
|---|---|---|
| Process Mode | Top of the editor | Design stores no table: elements built on the grain run its steps. Persist stores the grain's rows |
| Source element | Top of the editor | The acquisition or prep the steps start from |
| Sample | Top of the editor | Top 100, Top 1000, Top N with a number, or All for no sampling |
| of column | Beside Sample | The column whose first N values decide which rows stay |
| Bulk Copy Only | Top right, only when it applies | Shows that a step can't run in SQL Server. Click it to see which |
| Step Management | Left | Pick a step type and click Add. Drag a step to move it, or press Alt+Up and Alt+Down. Delete step removes the selected one |
| Step Designer | Right | The selected step's settings, under its Step name |
| Schema tab | Bottom | Column name, Column type and Mode of each column, up to the selected step |
| Data tab | Bottom | The rows up to the selected step |
Missing something?
Tell us what you were trying to do and what this guide didn't answer. We update it with every release.
Write to usWhat changed in this guide
- November 21, 2026: Reviewed against ConradBI 1.2.59.
- October 31, 2026: First edition, written for ConradBI 1.2.52.
