Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
tdhlonghorn
Helper I
Helper I

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

2 ACCEPTED SOLUTIONS
jdbuchanan71
Super User
Super User

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

View solution in original post

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

View solution in original post

6 REPLIES 6
jdbuchanan71
Super User
Super User

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

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?

@tdhlonghorn

No hay ninguna entrada de 'Ventas netas' en la tabla 'AbbrP&L' por lo que no aparece.

Esto desafortunadamente añade otra capa de complejidad; Había dejado mi tabla acumulativa abbrP&L para simplificar, pero también tendré que filtrar esa tabla. No puedo aplicar el filtrado bidireccional de la tabla de usuario dos veces, lo que me lleva con una de las dos opciones:

  1. Tener una tabla de usuario para cada nivel para el que tendré que filtrar (en realidad tres, porque también estoy filtrando por AcctNum, que también dejé para simplificar)
  2. Averiguar cómo hacer esto a través de DAX sin filtros bidireccionales

Me gustaría averiguar la opción 2, ¿es esto en absoluto posible?

Se ha actualizado .pbixy la captura de pantalla del modelo de datos a continuación:

tdhlonghorn_0-1598046385427.png

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

Esto funciona muy bien, gracias @jdbuchanan71 ! Modifiqué ligeramente para filtrar la tabla Cuentas (ya que también tendré que filtrar cuentas). No puedo esperar para construirlo en mi modelo real.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.