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
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
v-shex-msft
Community Support
Community Support

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 

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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

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.