Forum Discussion
DAX Measure to aggregate parent table values which preserving filter on child table
- 11 months ago
Hi XELANAMYT ,
There is no relationship between the parent and the Users table so there is no impact on the filter you are doing in the Users table.
Since you have a relationship of one to many from the users to the child, and the child is also on the many side of the relationship you are not getting the values filtered back to the parent.
Try something like this:
Measure2 = CALCULATE( AVERAGE('Parent'[ValPA]), ALLEXCEPT('Child', 'Zones'[Name], 'Categories'[Name], 'States'[Name], 'Users'[Name]), 'Parent'[ID] in VALUES('Child'[ParentID]) )Another option can also be:
Measure2 = CALCULATE( AVERAGE('Parent'[ValPA]), ALLEXCEPT('Child', 'Zones'[Name], 'Categories'[Name], 'States'[Name], 'Users'[Name]), CROSSFILTER('Parent'[ID],'Child'[ParentID], Both) )This one forces the cross filter between the tables to go either way from parent to child and from child to parent.
Use the columns that are being used on the relationship between parents and child.
The first measure is working properly because the Parent Table is a dimension table reagarding the child so every filter you apply to the parent is passed to the child.
Hi XELANAMYT ,
There is no relationship between the parent and the Users table so there is no impact on the filter you are doing in the Users table.
Since you have a relationship of one to many from the users to the child, and the child is also on the many side of the relationship you are not getting the values filtered back to the parent.
Try something like this:
Measure2 =
CALCULATE(
AVERAGE('Parent'[ValPA]),
ALLEXCEPT('Child', 'Zones'[Name], 'Categories'[Name], 'States'[Name], 'Users'[Name]),
'Parent'[ID] in VALUES('Child'[ParentID])
)
Another option can also be:
Measure2 =
CALCULATE(
AVERAGE('Parent'[ValPA]),
ALLEXCEPT('Child', 'Zones'[Name], 'Categories'[Name], 'States'[Name], 'Users'[Name]),
CROSSFILTER('Parent'[ID],'Child'[ParentID], Both)
)
This one forces the cross filter between the tables to go either way from parent to child and from child to parent.
Use the columns that are being used on the relationship between parents and child.
The first measure is working properly because the Parent Table is a dimension table reagarding the child so every filter you apply to the parent is passed to the child.