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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
jc508
Frequent Visitor

'LOOKUPVALUE' is not allowed as part of the row level security expression on DirectQuery models

In Power-BI we are connecting to SqlServer (NOT SSAS and NOT a tabular model)
and get the error 'LOOKUPVALUE' is not allowed as part of the row level security expression on DirectQuery models
We are trying to convert some reports to run without SSAS now that row level security is available in Power-Bi
The expression was lifted from the SSAS version we are migrating from.

https://docs.microsoft.com/en-us/sql/analysis-services/supplemental-lesson-implement-dynamic-securit...
updated 8th May still says this is the method to use.
If this function is not allowed then what functions are allowed ?

Syntax used is
'Fact Purchase Row Status'[DDS_COST_CODE_SK]=LOOKUPVALUE('Dimension User Cost Code Access'[DDS_COST_CODE_SK]
    , 'Dimension User Cost Code Access'[USERNAME_TXT], mid(username(), search("\", username()) + 1, 20)
    , 'Dimension User Cost Code Access'[DDS_COST_CODE_SK] ,'Fact Purchase Row Status'[DDS_COST_CODE_SK] )

4 REPLIES 4
Anonymous
Not applicable

Hi @jc508,

 

You can try to use calculate function with firstnonblank and filters to achieve lookup operation.

'Fact Purchase Row Status'[DDS_COST_CODE_SK] =
CALCULATE (
    FIRSTNONBLANK (
        'Dimension User Cost Code Access'[DDS_COST_CODE_SK],
        [DDS_COST_CODE_SK]
    ),
    FILTER (
        ALL ( 'Dimension User Cost Code Access' ),
        'Dimension User Cost Code Access'[USERNAME_TXT]
            = MID ( USERNAME (), SEARCH ( "\", USERNAME () ) + 1, 20 )
            && 'Dimension User Cost Code Access'[DDS_COST_CODE_SK]
                = SELECTEDVALUE ( 'Fact Purchase Row Status'[DDS_COST_CODE_SK] )
    )
)

 

In addition, you can also turn on below option to write unrestricted measures in directquery mode.

13.PNG

 

Regards,

Xiaoxin Sheng 

Thanks v-shex-msft

I tried that formula as is and it gets an error

'Function CALCULATE is not allowed as part of the row level security expression on DirectQuery models.'

 

Looks like there are no functions that you can use with row level security !!

 

Also ticking that option seems to make no difference - maybe only applies to measures not RLS filters ???

 

I will fiddle with it some more but thanks anyway

JC

Anonymous
Not applicable

Hi @jc508,

 

I guest you're try to create a calculated column in direct query mode, right? If this is a case, current most of functions not allowed to use in calculated column when you use direct query mode.

 

I'd like to suggest you use measure to instead.

 

Regards,

Xiaoxin Sheng

is this fixed by Microsoft or it is still the same issue?Is there any alternate method to do it?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors