Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have two relationships between two table: a contracts table and a price plans table. The active one is between the current price plan of the contract, and the inactive one is between the price plan at the beginning of the contract (users are allowed to shift between price plans during the contract). I would like to have a calculated column in my contract table showing the name of the first price plan. These codes do not work:
First Price Plan =
CALCULATE ( RELATED ( PricePlans[Price Plan] ), USERELATIONSHIP ( Contracts[First Price Plan ID], PricePlans[Price Plan ID]))
First Price Plan =
CALCULATE ( SELECTEDVALUE ( PricePlans[Price Plan] ), USERELATIONSHIP ( Contracts[First Price Plan ID], PricePlans[Price Plan ID]))
Why do these codes not work and what could work?
Solved! Go to Solution.
@simormate , USERELATIONSHIP can change the relationship in the case of measure. In the case of the column, you can simply use your choice of joins in the filter.
example
First Price Plan = minx (filter(PricePlans,Contracts[First Price Plan ID]= PricePlans[Price Plan ID]) PricePlans[Price Plan] )
refer : https://www.youtube.com/watch?v=czNHt7UXIe8
An article from sqlbi.com explaining the issue and solutions: https://www.sqlbi.com/articles/userelationship-in-calculated-columns/
@simormate , USERELATIONSHIP can change the relationship in the case of measure. In the case of the column, you can simply use your choice of joins in the filter.
example
First Price Plan = minx (filter(PricePlans,Contracts[First Price Plan ID]= PricePlans[Price Plan ID]) PricePlans[Price Plan] )
refer : https://www.youtube.com/watch?v=czNHt7UXIe8
You are in trouble here. USERELATIONSHIP is not able to change the connection between tables when you use it in a calculated column. Only the active relationship is always active when you define a calculated column. There are articles about this behaviour on www.sqlbi.com.
What you can do is use LOOKUPVALUE instead.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |