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.
We've build a model that uses a live connection to a few other models. We then used SELECTCOLUMS to create two calculated tables derived from those models, to review data and build reporting off. And finally, we connected two of those tables together.
One of the calculated tables uses a calculated column with RELATED to bring in columns from a one of the other calculated tables.
This all worked fine when built, but today the same calculated table is returning an error:
Meanwhile, here is how two two calculated tables actually appear in the model:
They are linked and the link works fine if we build a table visual.
Any ideas why DAX is playing up when it worked originally?
Solved! Go to Solution.
Hi @SevsBo
You're encountering this issue because the RELATED() function only works when there's a single-direction, many-to-one relationship from the current table to the lookup table. In your model, it appears that the relationship between Att_Inactive_Subaccounts and AttritionTable is many-to-many, which breaks RELATED().
To work around this, you can:
Use an iterative + aggregation pattern with RELATEDTABLE() and something like MINX, MAXX, or SELECTCOLUMNS, for example:
IF(
ISBLANK(
MINX(
RELATEDTABLE(AttritionTable),
AttritionTable[Subaccount ID]
)
),
"Inactive",
"Active"
)
Or: If possible, restructure the relationships in the source model (where the data is authored) to enforce a proper many-to-one direction. This may require help from the dataset owner or data modeler.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Hi @SevsBo
You're encountering this issue because the RELATED() function only works when there's a single-direction, many-to-one relationship from the current table to the lookup table. In your model, it appears that the relationship between Att_Inactive_Subaccounts and AttritionTable is many-to-many, which breaks RELATED().
To work around this, you can:
Use an iterative + aggregation pattern with RELATEDTABLE() and something like MINX, MAXX, or SELECTCOLUMNS, for example:
IF(
ISBLANK(
MINX(
RELATEDTABLE(AttritionTable),
AttritionTable[Subaccount ID]
)
),
"Inactive",
"Active"
)
Or: If possible, restructure the relationships in the source model (where the data is authored) to enforce a proper many-to-one direction. This may require help from the dataset owner or data modeler.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Hi @Ritaf1983
I'm not sure about the single-direction bit, but I think you're spot on regarding many-to-many! Example of a working bidirectional one-to-many relationship is below:
RELATED will only work across a regular relationship, from the many side to the one side, and you have a many-to-many relationship. You could use LOOKUPVALUE or SELECTCOLUMNS with FILTER to get the value.