The RELATED function in Power BI returns the value from a related table when a relationship exists between the two tables. Use it in a calculated column or a measure when you need to pull a field from the "one" side of a one-to-many relationship into the "many" side. For example, if you have a Sales table and a Product table linked by ProductID, RELATED lets you add the product name or category directly to the Sales table. It only works when a relationship is already defined and when the function can follow a single, unambiguous path from the current table to the target table. If no relationship exists, or if multiple relationships create ambiguity, RELATED returns an error or blank. Before you start, make sure your data model has the necessary relationship and that you know which table is on the "many" side and which is on the "one" side.
What You'll Need
- Power BI Desktop (or the Power BI service with edit permissions) and a dataset loaded into the model.
- At least two tables with a defined relationship. The relationship must be one-to-many or many-to-one; RELATED does not work with many-to-many relationships.
- Basic familiarity with the formula bar and creating calculated columns or measures.
Step-by-Step
- Open your report in Power BI Desktop and go to the Modeling view (the table icon on the left). This view shows your tables and the lines between them.
- Verify the relationship exists. Look for a line connecting the two tables. If there is no line, create one: drag the key field from one table onto the matching key field in the other table. A one-to-many relationship is created automatically if the data types match and one side has unique values. You can also right-click a table and choose Manage relationships to see all relationships. Labels may differ slightly by version, but the concept is the same.
- Identify the direction. RELATED works when you are on the "many" side and want a value from the "one" side. For example, if Sales has many rows per product and Product has one row per product, you can use RELATED in a calculated column on Sales to get Product[Category]. If you are on the "one" side and need a value from the "many" side, use RELATEDTABLE instead.
- Go to the Data view (the table icon with a grid) and select the table where you want to add the new column. This should be the table on the "many" side of the relationship.
- Create a new calculated column. On the Home tab, click New column. The formula bar appears.
- Write the RELATED formula. The syntax is:
ColumnName = RELATED(RelatedTable[ColumnName]). For example:ProductCategory = RELATED(Product[Category]). Replace RelatedTable and ColumnName with your actual table and field names. Use the exact names as they appear in the Fields pane; table names with spaces need single quotes, likeRELATED('Product Table'[Category]). - Press Enter to commit. Power BI evaluates the formula for each row in the current table. If a related row exists, it returns the value; otherwise it returns blank.
- Check the results. Scroll through the new column. Blanks indicate rows where no matching related record was found. That usually means missing or mismatched keys, or a relationship that does not cover all rows.
- Use the new column in visuals. You can now drag it into a table, matrix, slicer, or use it in measures. For example, use it to slice sales by product category without needing to bring the Product table into the visual.
Common Mistakes
- Using RELATED on the wrong side. RELATED only works from the "many" side to the "one" side. If you try it on the "one" side to get a value from the "many" side, you will get an error. Use RELATEDTABLE for that direction.
- No relationship defined. RELATED requires an existing relationship. If the tables are not linked, the function returns an error. Create the relationship first.
- Ambiguous relationships. If there are multiple relationships between the two tables, RELATED may not know which one to use. You can specify the relationship by using the full table name and column, but if ambiguity remains, you may need to use USERELATIONSHIP in a measure or redesign the model.
- Inactive relationships. RELATED only follows active relationships. If the relationship is inactive (dashed line), you must activate it or use USERELATIONSHIP in a measure.
- Many-to-many relationships. RELATED does not work with many-to-many relationships. You need a one-to-many or many-to-one relationship.
- Wrong table or column names. Typos in table or column names cause errors. Use the formula autocomplete to pick the correct names.
Tips
- Use RELATED in calculated columns when you want to denormalize data for simpler visuals. It can improve performance by avoiding extra joins in visuals.
- If you need to bring multiple columns from the related table, consider using RELATED multiple times or using LOOKUPVALUE as an alternative when no relationship exists.
- For measures, RELATED is often not needed because measures can filter across related tables automatically. Use RELATED mainly in calculated columns.
- Keep your relationships clean: one active relationship per pair of tables is easiest to manage.
- When you get blanks, check for missing keys or referential integrity issues. You can use the "Show items with no data" option in visuals to spot them.
Troubleshooting
If RELATED returns an error saying a relationship is missing, go back to the Modeling view and create the relationship. If it returns blanks, verify that the key values match exactly (including data type and case sensitivity). If you see an error about ambiguity, check for multiple relationships between the tables and remove or deactivate the extra ones, or use USERELATIONSHIP in a measure. If the function does not appear in autocomplete, make sure you are in a calculated column context, not a measure (though RELATED can be used in measures, it is less common). If the column you want is in a table that is not directly related, you may need to add an intermediate relationship or use a different function like LOOKUPVALUE. Always test on a small sample first.
Frequently Asked Questions
Can I use RELATED in a measure?
Yes, but it is less common because measures can usually access related tables through filter context. It works in measures when you need to retrieve a specific related value for the current row context, but be aware of context transition.
What is the difference between RELATED and RELATEDTABLE?
RELATED returns a single value from the "one" side of a relationship. RELATEDTABLE returns a table of all related rows from the "many" side. Use RELATED when you expect one related row; use RELATEDTABLE when you expect multiple.
Why does RELATED return blank?
Blank usually means no matching related row was found. Check that the key values match and that the relationship is active and correctly configured.
Can I use RELATED with many-to-many relationships?
No, RELATED requires a one-to-many or many-to-one relationship. For many-to-many, you need to restructure your model or use other DAX functions like TREATAS or CROSSFILTER.
Does RELATED work across multiple relationships?
It can follow a chain of relationships if they are all one-to-many and active, but it is safer to use direct relationships. If there are multiple paths, you may get an ambiguity error.
Is RELATED available in Power BI Desktop and the service?
Yes, DAX functions including RELATED are available in both Power BI Desktop and the Power BI service when you edit the model. The interface may differ slightly, but the function works the same.