Forum Discussion
WinterMist
1 year agoImpactful Individual
Conditionally Filter Specific Visuals Based on Current User Logged In
Hello Community - If someone could provide guidance, I would appreciate it. Here is a link to the PBIX: https://drive.google.com/file/d/1IPk0O0nXhVVXXCOU0yLUtRwYL6RGLtyo/view?usp=sharing ...
- 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
johnt75
1 year agoSuper User
You can do this with a calculation group and a measure to use as a filter.
First you need to modify your measure
02 Should Current User Be Filtered =
VAR CSRFilterEmailList =
//ONLY NON-MANAGER CSR'S SHOULD HAVE DATA FILTERED
CALCULATETABLE(
ALL('Dim CSR'[Email]),
'Dim CSR'[IsManager] = 0
)
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
Rather than using VALUES it uses ALL to remove the filters placed by the visuals.
Create a calculation group with a calcultion item
Apply Filter = IF( [02 Should Current User Be Filtered],
CALCULATE(
SELECTEDMEASURE(),
KEEPFILTERS( TREATAS( { [01 Current User] }, 'Dim CSR'[Email] ) )
),
SELECTEDMEASURE()
)
Apply this as a filter to the table visual. It will only show the relevant CSRs.
Create a new measure
Is CSR Visible = IF (
[02 Should Current User Be Filtered],
VAR VisibleEntries =
CALCULATETABLE (
VALUES ( 'Dim CSR'[Name] ),
TREATAS ( { [01 Current User] }, 'Dim CSR'[Email] )
)
VAR Result =
IF ( SELECTEDVALUE ( 'Dim CSR'[Name] ) IN VisibleEntries, 1, 0 )
RETURN
Result,
1
)
Add this as a filter to the slicer, to only show when the value is 1.
See the attached PBIX for a working example