Sub topic 11
Choosing the right approach for your model
This chapter assumes you can build a star schema in Power BI or Analysis Services Tabular and write simple DAX measures. It also assumes you know CALCULATE, filter context, and the difference between active and inactive relationships. By now you have seen three ways to report one fact table by more than one date role: USERELATIONSHIP, a duplicated Date table, and a calculation group. This chapter gives you criteria for choosing among them.
The three approaches in one view
Every approach answers the same question: how does a single Date table filter Sales by order date in one place and by ship date in another?
- USERELATIONSHIP. The model keeps one Date table. The
Sales[OrderDate]relationship is active. TheSales[ShipDate]relationship is inactive. A measure activates it for one calculation. - Duplicated dimension. The model has two Date tables, such as
'Date'and'Ship Date'. Each has its own active relationship toSales. - Calculation group. The model keeps one Date table and inactive relationships. A calculation item wraps
SELECTEDMEASURE ()inUSERELATIONSHIP, so the user picks the date role with a slicer.
The recap below shows the key code for each approach.
-- Approach 1: USERELATIONSHIP in a dedicated measure
Sales Amount by Ship Date =
CALCULATE (
[Sales Amount],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] )
)-- Approach 2: a duplicated Date table (calculated table)
Ship Date = 'Date'-- Approach 3: a calculation item in a calculation group
CALCULATE (
SELECTEDMEASURE (),
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] )
)With approach 2, the base measure [Sales Amount] needs no changes. You filter it with 'Ship Date'[Year] instead of 'Date'[Year].
How the approaches differ
The table compares the approaches on the dimensions that usually decide the choice.
| Dimension | USERELATIONSHIP | Duplicated Date table | Calculation group |
|---|---|---|---|
| Number of Date tables | One | One per role | One |
| Measures needed | One extra measure per role and base measure | None extra | One calculation item per role |
| Both roles in one visual | Yes, with separate measures | Yes, by using both tables | Needs care, see below |
| Slicing by ship-date attributes | Only through the main Date table, which is active for the order date | Yes, through the `'Ship Date'` table | Same limit as `USERELATIONSHIP` |
| Model size | Smallest | Larger, since the table is copied | Smallest |
| Tooling | Standard DAX | Standard DAX | Needs Tabular Editor or equivalent in many setups |
| Risk of user confusion | Measure names carry the role | Field lists show two similar tables | Slicer state changes every measure |
Where the filter comes from
The most important difference is which table the user filters. A date slicer from 'Date' filters Sales through whichever relationship is active at that moment.
With USERELATIONSHIP, the measure changes which relationship is active. The slicer is still from 'Date'. If a user selects "2025" on a 'Date'[Year] slicer, Sales Amount returns sales ordered in 2025. Sales Amount by Ship Date returns sales shipped in 2025. One slicer produces two different meanings, depending on the measure. That is useful when you want one filter, and confusing when the report does not say which date is in use.
With a duplicated table, each role has its own slicer. A user can select orders from 2025 on 'Date' and shipments from December on 'Ship Date'. Both filters apply together. This is something USERELATIONSHIP cannot do, because inside a single calculation only one of the two relationships is used for the 'Date' table.
Late Shipments Amount =
CALCULATE (
[Sales Amount],
'Date'[Year] = 2025,
'Ship Date'[Year] = 2026
)This measure works only with the duplicate. It returns sales ordered in 2025 and shipped in 2026. Without a second table, you would need to write the second filter another way, for example as a filter on the Sales[ShipDate] column itself, which loses the Date table's attributes.
A decision flow
Use the flow below as a starting point. It does not replace judgment about your own model.
Questions to ask first
- Will users filter by two roles in the same report page? If a page needs a slicer for order month and another for ship month, use separate Date tables.
USERELATIONSHIPcannot give two simultaneous Date table filters. - How many measures need an alternate version? Two or three measures justify hand-written
USERELATIONSHIPmeasures. Thirty measures do not, because each new base measure needs its own ship-date copy that you must keep in sync. - How many date roles are there? Order, ship, and due dates mean three roles. Each extra role multiplies measures under
USERELATIONSHIPand adds one calculation item under a calculation group. - Who maintains the model? A calculation group is a model-level object. Some authoring tools cannot create one, so confirm that your team's tools support it before you commit to it.
- Is model size a concern? A Date table is small, so duplicating it costs little. Size rarely decides this question, but it can matter when the Date table carries many columns or when you need many roles.
When USERELATIONSHIP is the right choice
Choose USERELATIONSHIP when the alternate role is a secondary view of the data. A typical case is a report that is mostly about order date, with a small number of "by ship date" measures.
Its advantages are practical.
- You keep one Date table, so the field list stays short.
- Hierarchies, sort-by-column settings, and the date-table marking apply to one table only.
- The measure name states the role, such as
Sales Amount by Ship Date. - It uses only standard DAX and works in every tool.
Its limits follow from the same design.
- Every measure that needs the alternate role needs its own version.
- The ship-date measures must be placed on visuals that use
'Date'attributes. They give the right result only when the user understands that the slicer applies to ship date for that measure. - You cannot filter by two roles at once through the same table.
Time intelligence stays simple
Time intelligence combines easily with this approach, because the filter on the Date table passes through whichever relationship the measure activates.
Shipped Sales YTD =
CALCULATE (
[Sales Amount],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] ),
DATESYTD ( 'Date'[Date] )
)With a duplicate table, the same result needs time intelligence functions over the duplicate. You would write DATESYTD ( 'Ship Date'[Date] ). That works only if the duplicate is also a properly marked or continuous date table. If you duplicate without checking that, time intelligence may return wrong or blank results.
When a duplicated Date table is the right choice
Choose a duplicate when users must treat the roles as independent dimensions. Typical signs are:
- A page has separate slicers for order date and ship date.
- A matrix puts order month on rows and ship month on columns.
- Business users think of "Ship Date" as its own dimension and expect to find it in the field list.
- You want base measures such as
[Sales Amount]to work on either role without writing variants.
The matrix case is a good test. You cannot build it with USERELATIONSHIP alone, because one measure evaluation uses one active relationship to 'Date'. With two tables, the matrix works with the plain base measure, because each Date table filters through its own active relationship.
Costs of duplication
- Every Date table needs the same configuration: hierarchies, sort-by-column, formatting, and date-table marking. A change made to one is easy to miss on the others.
- A calculated table copies the data at refresh, but it does not copy column properties. Check sort order and formats after you create it.
- The field list contains two or more near-identical tables. Name them clearly and hide any columns users do not need.
- Column names repeat across tables. Consider renaming the duplicate's columns, for example
Ship Year, so that visuals show unambiguous headers. - Relationships from the duplicate to
Salesuse the same fact column that the inactive relationship used. You should remove the inactive relationship to the original Date table when you add the duplicate, or the model will carry an unused relationship.
When a calculation group is the right choice
Choose a calculation group when many measures need the same alternate role and the user should switch roles with a selector. The calculation item applies USERELATIONSHIP to any measure.
-- Calculation item "Ship Date"
CALCULATE (
SELECTEDMEASURE (),
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] )
)You also normally add an "Order Date" item that returns SELECTEDMEASURE () unchanged, so that the selector has a default.
Consider these points before you commit.
- Selector state. The calculation group column is a slicer or filter. If a user clears it, the behavior depends on your model's setup. Define what the model should do with no selection.
- Mixed roles on one page. A single selector gives every visual on the page the same role. Two measures cannot show different roles side by side unless you add explicit items or use measures that bypass the group.
- Measure interaction. Calculation items apply to every measure in scope. Measures that already contain
USERELATIONSHIP, or that ignore filters on the Date table, may produce results you do not intend. Test each measure. - Tooling. Creating the group usually needs an external tool such as Tabular Editor, or a compatible modeling interface. Plan for this in your deployment process.
- Visibility. Users cannot see the role from a measure name. Show the selected role in a title or label.
Combining approaches
The approaches are not exclusive. A common production design uses a duplicate Date table for the roles that users need to slice independently, such as order and ship date. It adds a calculation group for the cases where the same measures need to be viewed by a role that has no duplicate. Both rely on the same fact table and the same base measures.
Combine them only when a requirement demands it. Every extra mechanism makes the model harder to explain. If one approach meets the requirements, use that one.
Worked example: choosing for a sales model
Suppose a Sales table has OrderDate, ShipDate, and DueDate. The model has a 'Date' table with an active relationship on OrderDate. The requirements are:
- The main dashboard reports 12 measures by order date.
- Operations needs three measures by ship date: sales amount, quantity, and shipped sales YTD.
- Nobody has asked for due date.
- No report needs order and ship date filters together.
Walk through the questions.
- Two roles at once? No. So duplication is not forced.
- How many measures need the alternate date? Three. That is a small number, so hand-written measures are cheap.
- Number of roles? One alternate role is in use. Due date has no requirement.
- Tools? Standard DAX is enough.
The best choice is USERELATIONSHIP. Create the three measures, name them clearly, and keep the due-date relationship inactive until someone needs it.
Now change the requirements. Operations asks for a matrix with order month on rows and ship month on columns. Direct USERELATIONSHIP measures cannot supply both axes. Create the 'Ship Date' table, relate it to Sales[ShipDate], and use the base measures. The three ship-date measures become unnecessary, so delete them once the reports use the new table. Leaving both in place gives users two ways to get the same number.
Common selection mistakes
- Choosing a calculation group for two measures. The setup cost exceeds the saving.
- Writing 30
USERELATIONSHIPmeasures. The model becomes hard to maintain, and a fix to one measure must be repeated. - Duplicating the Date table without marking it. Time intelligence on the copy may fail or return blank values.
- Leaving the old inactive relationship in place after adding a duplicate. It is unused and invites confusion.
- Assuming a slicer changes the role. A
'Date'slicer does not change the relationship. Only the measure or the calculation item does.
Summary of criteria
- Use
USERELATIONSHIPfor a few alternate-date measures and one filtering Date table. - Use a duplicated Date table when roles must be filtered or shown together.
- Use a calculation group when many measures need the same role switch and the team can maintain one.
- Combine approaches only for a stated requirement.
Exercise
A model has a Sales table with OrderDate and ShipDate, and a Date table that has an active relationship to OrderDate. A report page needs a slicer on order year and a second slicer on ship year, used together, with the existing [Sales Amount] measure. Which approach fits, and why can USERELATIONSHIP not do it alone?
Show answer
Duplicate the Date table (for example, Ship Date = 'Date'), relate it to Sales[ShipDate] with an active relationship, and slice by each table. USERELATIONSHIP alone cannot work because a measure activates one relationship between Sales and 'Date' at a time, so it cannot apply an order-year filter and a ship-year filter from the same Date table in one evaluation. The duplicate gives each role its own table and its own filter, and [Sales Amount] works unchanged.
Exercise
An operations team needs 25 existing measures available by ship date, and users want a slicer to switch the whole page between order date and ship date. Nobody needs both roles filtered at once. Which approach fits, and what must you define for the selector?
Show answer
A calculation group fits. Add an "Order Date" item that returns SELECTEDMEASURE () and a "Ship Date" item that wraps SELECTEDMEASURE () in CALCULATE with USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] ). You avoid writing 25 extra measures. You must define the behavior when no item is selected, for example by making the order-date item the default, and label the page so users can see which role is active.