Forum Discussion

WinterMist's avatar
WinterMist
Impactful Individual
1 year ago
Solved

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   ...
  • johnt75's avatar
    johnt75
    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