The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
So I want to make a calculated column that takes a value in another table and I would usually use the RELATED function but I can't since they are related with an inactive relationship. Is there any way to do that ?
Here is a screenshot of the tables and the inactive relationship :
I want to put the related CODE1 in Daily Operation Table
Hi @Anonymous ,
Based on what 123abc said, here are some of my additions.
When dealing with inactive relationships in Power BI or other DAX-based tools, you can use the USERELATIONSHIP function to temporarily activate the inactive relationship for a specific calculation.
The RELATED function is a value function that returns the relevant values from the association table. The USERELATIONSHIP function is used to activate an inactive relationship, and the arguments are the two columns that make up the relationship.
You can read this two documents for a further study: RELATED function (DAX) - DAX | Microsoft Learn and USERELATIONSHIP function (DAX) - DAX | Microsoft Learn
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
In Power BI, when you have an inactive relationship between tables and you want to use the RELATED function or something similar to access values from another table, you can utilize USERELATIONSHIP in your DAX calculations. Here's how you can achieve this:
Suppose you have two tables: "Daily Operation Table" and "Category Table" with an inactive relationship between them based on the "CODE" column.
Let's say you want to bring the "CODE1" value from the "Category Table" into the "Daily Operation Table" using DAX. You can use the USERELATIONSHIP function to specify the inactive relationship. Here's an example of how you can create a calculated column in the "Daily Operation Table" to achieve this:
RelatedCode1 =
VAR SelectedCategory = 'Daily Operation Table'[Category] // Assuming 'Category' is the related column
RETURN
CALCULATE (
VALUES ( 'Category Table'[CODE1] ),
USERELATIONSHIP ( 'Category Table'[CODE], 'Daily Operation Table'[Category] )
)
In this formula:
Ensure that you replace 'Category' with the actual name of the related column in the "Daily Operation Table" and adjust the column names as per your data model. This DAX expression should allow you to retrieve the related "CODE1" values even with the inactive relationship.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
I'm popping in way after you posted this solution to say, thanks! This helped me work out something in my report.
Only thing is I had to add a second filter condition to the Calculate, something like 'Category Table'[CODE]=SelectedCategory. Otherwise I was getting an array instead of one value.
User | Count |
---|---|
25 | |
10 | |
8 | |
6 | |
5 |
User | Count |
---|---|
31 | |
10 | |
10 | |
10 | |
9 |