Forum Discussion
Measure based on report level filter
- 7 years ago
To achieve this you will need a new table that has a distinct list of all names from both the owner and manager tables.
You can do this by creating a calcuated table with the following code
Person = DISTINCT(UNION(DISTINCT('Table'[Account Owner]),DISTINCT('Table'[Account Owner])))Note: I would rename the "Account Owner" column in this table after you've created it to something like "Person Name"
Then you could create a slicer on this new table and create a measure like the following which will do the OR filter on either column. Then when ever you using this measure with the Person Name slicer it will filter on both Owner and Manager names.
Total Sales = CALCULATE( SUM('Table'[Sales]), FILTER(ALL('Table'[Account Owner],'Table'[Manager Name]), 'Table'[Account Owner] in values(Person[Person Name]) || 'Table'[Manager Name] in VALUES(Person[Person Name]) ) )
To achieve this you will need a new table that has a distinct list of all names from both the owner and manager tables.
You can do this by creating a calcuated table with the following code
Person = DISTINCT(UNION(DISTINCT('Table'[Account Owner]),DISTINCT('Table'[Account Owner])))Note: I would rename the "Account Owner" column in this table after you've created it to something like "Person Name"
Then you could create a slicer on this new table and create a measure like the following which will do the OR filter on either column. Then when ever you using this measure with the Person Name slicer it will filter on both Owner and Manager names.
Total Sales =
CALCULATE(
SUM('Table'[Sales]),
FILTER(ALL('Table'[Account Owner],'Table'[Manager Name]),
'Table'[Account Owner] in values(Person[Person Name])
|| 'Table'[Manager Name] in VALUES(Person[Person Name])
)
)I wound up making a hybrid to this approach and simply building a measure to accomplish this instead of using the measure to help filter the data. Apparently Power BI does not like it when you do this and does not retain filter context when evaluating a measure inside a filter.