Forum Discussion

tdhlonghorn's avatar
tdhlonghorn
Icon for Helper I rankHelper I
6 years ago
Solved

Filtrado dinámico de RLS de varias tablas

Hola Tengo un modelo .pbix de prueba creado y estoy tratando de implementar la seguridad de nivel de fila, pero estoy en problemas al pasar varios filtros a través de DAX en Administrar roles. Mi...
  • jdbuchanan71's avatar
    6 years ago

    @tdhlonghorn

    En realidad, no necesita que la tabla de seguridad se una a su modelo. Sólo tiene que utilizar una medida para leer el USERPRINCIPALNAME() y crear la lista de 'AbbrP&L'[Abbr P&L] cuentas que el usuario puede ver. Un cambio que necesitará es hacer la unión entre UserProfileAbbrP&L y Profile Bridge bidireccional.

    jdbuchanan71_0-1597892837087.png

    A continuación, el filtro en la tabla AbbrP&L se ve así.

    'AbbrP&L'[Abbr P&L] IN 
    CALCULATETABLE(
        VALUES('ProfileAbbrP&L'[Abbr P&L Account]),'UserProfileAbbrP&L'[User]=USERPRINCIPALNAME())

    jdbuchanan71_1-1597892959684.png

    jdbuchanan71_2-1597893018561.png

    He adjuntado mi copia actualizada de su archivo para que lo mire.

  • jdbuchanan71's avatar
    jdbuchanan71
    6 years ago

    Su ProfileAbbrP&L ya contiene las cuentas y los paquetes acumulativos que un perfil puede ver. Sólo tiene que mover los rollups a la tabla AbbrP&L para que tenga este aspecto:

    jdbuchanan71_0-1598065806912.png

    Puede quitar las tablas acumulativas del lado del perfil y volver a establecer UserProfileAbbrP&L > AbbrProfileBridge en bidireccional. Entonces tu medida de filtrado se ve así.

    VAR _UPN = USERPRINCIPALNAME()
    RETURN
    'AbbrP&L'[Abbr P&L] IN 
        CALCULATETABLE(
            VALUES('ProfileAbbrP&L'[Abbr P&L Account]),'UserProfileAbbrP&L'[User]=_UPN)
    ||
    'AbbrP&L'[Rollup] IN 
        CALCULATETABLE(
            VALUES('ProfileAbbrP&L'[Abbr P&L Account]),'UserProfileAbbrP&L'[User]=_UPN)

    El modelo termina pareciéndose así.

    jdbuchanan71_1-1598066062096.png

    Y el RLS mostrará todas las cuentas o rollups asignados al perfil en la tabla [ProfileAbbrP&L]:

    jdbuchanan71_3-1598066238444.png