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 modelo de datos tiene este aspecto:

tdhlonghorn_0-1597877242548.png

Puedo filtrar correctamente el primero con el siguiente código:

tdhlonghorn_1-1597877355736.png

También en forma de texto:

[Perfil] En
SELECTCOLUMNS(
FILTER('UserProfileAbbrP&L',
'UserProfileAbbrP&L'[Usuario] á USERPRINCIPALNAME()
),
"Perfil", [Perfil]
)

Pero estoy sacando el mejor método para filtrar la tabla AbbrP&L:

tdhlonghorn_2-1597877429157.png

También en forma de texto:

[Abbr P&L] En
SELECTCOLUMNS(
FILTER('ProfileAbbrP&L',
'ProfileAbbrP&L'[Cuenta de Abbr P&L])
) EN
SELECTCOLUMNS(
FILTER('UserProfileAbbrP&L',
'UserProfileAbbrP&L'[Usuario] á USERPRINCIPALNAME()
),
"Abbr P&L", [Abbr P&L]
)

¿Qué me estoy perdiendo? Creo que necesito mantener la estructura tal cual (con la tabla De puente de perfil calculada) porque habrá varias instancias de Profile en las tablas UserProfile & ProfileAbbrP&L, pero estoy abierto a sugerencias. También me gustaría evitar pasar aplicando filtros en ambas direcciones si es posible.

Gracias de antemano,

Tom

  • @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.

  • 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

6 Replies

  • @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.

    • tdhlonghorn's avatar
      tdhlonghorn
      Icon for Helper I rankHelper I

      Gracias por la respuesta y la educación, @jdbuchanan71! Sin embargo, un elemento del filtro no parece funcionar correctamente. El perfil "Tiendas minoristas" debe filtrarse a Tiendas minoristas y Ventas netas según la tabla ProfileAbbrP&L, ¿necesito modificar el enfoque de alguna manera?