Forum Discussion
Conditionally Filter Specific Visuals Based on Current User Logged In
- 1 year ago
You can't use VALUES on its own, as the CSR table is being filtered by having the CSR name in the slicer or table visual. I think the below works, using REMOVEFILTERS
02 Should Current User Be Filtered = VAR CSRFilterEmailList = //ONLY NON-MANAGER CSR'S SHOULD HAVE DATA FILTERED CALCULATETABLE( VALUES('Dim CSR'[Email]), 'Dim CSR'[IsManager] = 0, REMOVEFILTERS( 'Dim CSR'[Name] ) ) VAR CurrentUser = [01 Current User] VAR ShouldCurrentUserBeFiltered = //VERIFY IF CURRENT USER LOGGED IN IS A NON-MANAGING CSR. //IF YES THEN WE NEED TO FILTER CSR SLICER & CSR TABLE VISUALS BY CURRENT USER LOGGED IN //IF NO THEN DO NOTHING. I.E. DO NOT FILTER THESE VISUALS BY THE CURRENT USER LOGGED IN IF( CONTAINS(CSRFilterEmailList, 'Dim CSR'[Email], CurrentUser), 1, 0 ) RETURN ShouldCurrentUserBeFiltered
Thank you also for your attempt to resolve this.
Unfortunately, this doesn't work.
Thank you very much for attaching the PBIX.
By replacing VALUES with ALL, within [02 Should Current User Be Filtered], this causes the measure to always return 1, regardless of whether the user is in the list of CSR Non-Managers or not. This is not right.
- It should return 1 only for CSR Non-Managers (CSR 1, CSR 2, CSR 4).
- It should return 0 for everyone else (CSR 3, CSR 5, or anyone else not in the first group).
However, the measure now incorrectly returns 1 for CSR 3 & CSR 5, when it should return 0.
For managers (CSR 3 & CSR 5), NOTHING should be filtered.
When Current User = CSR 3 or CSR 5....
- [02 Should Current User Be Filtered] = 1 (but should be 0).
- CSR Slicer should should NOT be filtered, but it is.
- CSR Summary table should NOT be filtered, but it is.
In summary, replacing VALUES with ALL in measure [02 ...] breaks the measure so that it only returns 1, all the time, regardless of the Current User.
NOTE: It is critical that [02 Should Current User Be Filtered] correctly returns:
- 1 IF the current user SHOULD be filtered (AND)
- 0 IF the current user should NOT be filtered.
Let me know if you have any additional suggestions.
Thanks again very much for your time.
Regards,
Nathan
You can't use VALUES on its own, as the CSR table is being filtered by having the CSR name in the slicer or table visual. I think the below works, using REMOVEFILTERS
02 Should Current User Be Filtered =
VAR CSRFilterEmailList =
//ONLY NON-MANAGER CSR'S SHOULD HAVE DATA FILTERED
CALCULATETABLE(
VALUES('Dim CSR'[Email]),
'Dim CSR'[IsManager] = 0,
REMOVEFILTERS( 'Dim CSR'[Name] )
)
VAR CurrentUser = [01 Current User]
VAR ShouldCurrentUserBeFiltered =
//VERIFY IF CURRENT USER LOGGED IN IS A NON-MANAGING CSR.
//IF YES THEN WE NEED TO FILTER CSR SLICER & CSR TABLE VISUALS BY CURRENT USER LOGGED IN
//IF NO THEN DO NOTHING. I.E. DO NOT FILTER THESE VISUALS BY THE CURRENT USER LOGGED IN
IF(
CONTAINS(CSRFilterEmailList, 'Dim CSR'[Email], CurrentUser),
1,
0
)
RETURN ShouldCurrentUserBeFiltered