Forum Discussion
USERELATIONSHIP Issue
Hi Oliver_Buchanan
Thanks for all the testing you've done — that detail really helps.
The key clue is that your measure returns the MAX of the whole ActionEvent table. That means no filter is reaching ActionEvent at all.
Here's why. USERELATIONSHIP switches a relationship on, but it doesn't change which way the filter flows. Your relationship goes one-to-many from ActionEvent to Action, so filters naturally flow from ActionEvent down to Action. Your measure needs the opposite — it filters on Action and reads from ActionEvent. That direction simply isn't open, so nothing gets filtered.
The CROSSFILTER measure suggested earlier didn't test this properly, because it was missing USERELATIONSHIP. Without that, the relationship stayed switched off. You need both together:
************************************************
CollectionActionEventTimeuse = CALCULATE ( MAX ( 'ActionEvent'[Created] ), USERELATIONSHIP ( 'Action'[CollectionActionEventKey], 'ActionEvent'[ActionEventKey] ), CROSSFILTER ( 'Action'[CollectionActionEventKey], 'ActionEvent'[ActionEventKey], BOTH ) )
************************************************
If that still doesn't work, run this in DAX Studio to see what your model has actually saved for each relationship:
************************************************
EVALUATE INFO.RELATIONSHIPS ()
************************************************
Look at ToCardinality, CrossFilteringBehavior and IsActive for the one you're activating. Web-based semantic models don't validate these settings when you create them, so they aren't always what you'd expect.
Either way, your TREATAS measure is perfectly fine to keep — it filters the column directly, so it avoids this problem entirely.
References:
USERELATIONSHIP function
CROSSFILTER function
Model relationships in Power BI Desktop
Thanks,
C Srikanth
Community Support Team
- Oliver_Buchanan21 days ago
Helper I
Hi C Srikanth,
Appreciate your time to look at this one!
The Relationship in question as shown in DAX studio
I've tried the measure you've suggested as above and unfortunately it still doesn't work :(
It still seems to pull the value as if its using the active relationship between the two tables, instead of the inactive relationship which defines the relationship from Action directly to that row where the event is 'pickup'. Again i've validated the keys are working and are correct as these joins work without issue in SQL. So this is only an issue in DAX.
Also as an note I did already try previously setting the inactive relationship in the semantic model to both ways, which also didn't work. I also tried it again now with your measure and still doesn't work.I've raised this as a bug with Microsoft.