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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
dlagos
Regular Visitor

Filter Dinamic for USER

I have this dax but don´t work by user... how can a fix this??

    MEASURE '02-Cal Real'[01-Real Dinamico] =
   
VAR Real = '02-Cal Real'[01-Real]

VAR Usuario = USERPRINCIPALNAME()

VAR UsuarioActual = FILTER('Maestro RLS',
'Maestro RLS'[Correo electrónico] = Usuario)

VAR CCActual = SELECTCOLUMNS(UsuarioActual,"@CC",
'Maestro RLS'[CC])

RETURN
CALCULATE(Real,'Centro de Costo'[DEPENDENCIA (Oracle)] IN CCActual)

EVALUATE
    SUMMARIZECOLUMNS('01-Calendario'[Año],'01-Calendario'[Nombre Corto Mes],'Centro de Costo'[DEPENDENCIA (Oracle)],
        "01-Real", '02-Cal Real'[01-Real Dinamico]
    )
4 REPLIES 4
Anonymous
Not applicable

Hi @dlagos 

 

It looks like there are a few issues with the DAX code you provided. Here are some steps you can take to fix it:

 

Wrap USERPRINCIPALNAME() in a CALCULATE function, this ensures that the function is used within a row context. Use CALCULATETABLE for FILTER and SELECTCOLUMNS, this helps create a row context for these functions. Ensure the IN operator is used within a CALCULATE function, this also helps create a row context.

MEASURE '02-Cal Real'[01-Real Dinamico] =
VAR Real = '02-Cal Real'[01-Real]
VAR Usuario = CALCULATE(USERPRINCIPALNAME())
VAR UsuarioActual = CALCULATETABLE(
    FILTER('Maestro RLS', 'Maestro RLS'[Correo electrónico] = Usuario)
)
VAR CCActual = CALCULATETABLE(
    SELECTCOLUMNS(UsuarioActual, "@CC", 'Maestro RLS'[CC])
)
RETURN
CALCULATE(Real, 'Centro de Costo'[DEPENDENCIA (Oracle)] IN CCActual)

EVALUATE
SUMMARIZECOLUMNS(
    '01-Calendario'[Año],
    '01-Calendario'[Nombre Corto Mes],
    'Centro de Costo'[DEPENDENCIA (Oracle)],
    "01-Real", '02-Cal Real'[01-Real Dinamico]
)

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

dlagos_0-1737032400031.png

it doesn't work, but is really good idea  

rajendraongole1
Super User
Super User

Hi @dlagos  - Improvised measure as below:

 

MEASURE '02-Cal Real'[01-Real Dinamico] =
VAR Real = '02-Cal Real'[01-Real]
VAR Usuario = USERPRINCIPALNAME()

-- Filter the Maestro RLS table to get the current user's row
VAR UsuarioActual = FILTER('Maestro RLS', 'Maestro RLS'[Correo electrónico] = Usuario)

-- Get the list of CC values for the current user
VAR CCActual = SELECTCOLUMNS(UsuarioActual, "@CC", 'Maestro RLS'[CC])

-- Check if CCActual has values and apply the filter dynamically
RETURN
IF (
ISBLANK(CCActual),
BLANK(),
CALCULATE(
Real,
'Centro de Costo'[DEPENDENCIA (Oracle)] IN VALUES(CCActual[@CC])
)
)

 

Ensure that row-level security (RLS) is properly configured in Power BI and the Maestro RLS table is included in the model.

 

Hope this helps.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





dlagos_0-1736519226620.png

Now i have this error

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.