Forum Discussion
Tackle Many to many relationship ?
Hello everyone,
I'm working on a tableau migration, and in tableau I have one report to migrate, in this report, the following measure is create:
sum([Threshold Value]*[Weight])/SUM(IIF(ISNULL([Value]),0,[Weight]))
So when you see this measure, you think it will be an easy one, but once you start to have a look on the model behind, the issue starts to come...
This is the model (I rebuilt in Power BI to get something more clear)
So the first part of the formula was pretty easy to build; I just use the bridge table in this table I add the following calculated column:
- Anonymous1 year ago
Hi Anonymous ,
The RELATED function only works in many-to-one or one-to-one relationships because it is designed to return a single value. In a many-to-many relationship, there may be multiple related values and it is impossible to determine which value to return.
Since you created the relationship, you can calculate it directly without creating a calculated column by creating a measure, you can write it as:
DIVIDE ( SUM ( 'BridgeTable'[the calculated column'] ) * SUM ( 'tab_weight'[weight] ), IF ( MAX ( 'tab_indicators'[value] ) = BLANK (), 0, SUM ( 'tab_weight'[weight] ) ) )If the problem persists, can you provide .pbix file with sensitive data removed or a portion of each table to help the problem be resolved more quickly?
Best Regards,
Zhu
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- AnonymousNot applicable
Hi Anonymous ,
The RELATED function only works in many-to-one or one-to-one relationships because it is designed to return a single value. In a many-to-many relationship, there may be multiple related values and it is impossible to determine which value to return.
Since you created the relationship, you can calculate it directly without creating a calculated column by creating a measure, you can write it as:
DIVIDE ( SUM ( 'BridgeTable'[the calculated column'] ) * SUM ( 'tab_weight'[weight] ), IF ( MAX ( 'tab_indicators'[value] ) = BLANK (), 0, SUM ( 'tab_weight'[weight] ) ) )If the problem persists, can you provide .pbix file with sensitive data removed or a portion of each table to help the problem be resolved more quickly?
Best Regards,
Zhu
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.