Forum Discussion
Issues with filtering when a specific measure is applied
- Anonymous2 years ago
Hi Anonymous ,
As you correctly point out, this issue is related to the filter context. When filters are applied, they change the context in which the metric is calculated.
Please try:
MonthVSAverage = VAR SelectedDepartment = SELECTEDVALUE('Department'[DepartmentName]) RETURN IF( SelectedDepartment = "A", CALCULATE( IF( ISBLANK(MAX('Table'[Average Rating Past Month])), "No reviews past month", MAX('Table'[Average Rating Past Month]) - MAX('Table'[Overall Average Rating]) ), 'Department'[DepartmentName] = SelectedDepartment ) )You can change 'SelectedDepartment' to whatever data you have in the Filter, in this case 'A' 'B' 'C'.
I know it is a bit of a pain in the ass but it is an alternative.
The result is ideal.
If you have any other questions please feel free to contact me.
The pbix file is attached.
Best Regards,
Yang
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.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Hi Anonymous ,
As you correctly point out, this issue is related to the filter context. When filters are applied, they change the context in which the metric is calculated.
Please try:
MonthVSAverage =
VAR SelectedDepartment = SELECTEDVALUE('Department'[DepartmentName])
RETURN
IF(
SelectedDepartment = "A",
CALCULATE(
IF(
ISBLANK(MAX('Table'[Average Rating Past Month])),
"No reviews past month",
MAX('Table'[Average Rating Past Month]) - MAX('Table'[Overall Average Rating])
),
'Department'[DepartmentName] = SelectedDepartment
)
)
You can change 'SelectedDepartment' to whatever data you have in the Filter, in this case 'A' 'B' 'C'.
I know it is a bit of a pain in the ass but it is an alternative.
The result is ideal.
If you have any other questions please feel free to contact me.
The pbix file is attached.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Hi Anonymous ,
Yes that worked! It is unfortunate that the SelectedDepartment needs to be predefined because that makes things tricky but I can probably work around it.
Thanks for your help 🙂