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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
adharia
Frequent Visitor

Error while implementing dynamic row level security

Hi,

 

I am trying to implement dynamic row level security on my reports. I followed the entire instructions that has been provided in https://community.powerbi.com/t5/Community-Blog/Different-approach-to-Dynamic-Row-Level-Security/bc-... .

 

Also I tried performing following steps:

 

  1. I created Manual table with 3 columns USER, EMAIL, Departments
  2. I executed this Dax query  "=IF(CUSTOMDATA()="OK", "Correct Custom data in connection string", "No custom data in connection string property or unexpected value") "
  3. After this I executed this query “Username = IF(CONTAINS(Roles,Roles[USER], USERNAME()), "Allowed", BLANK())” this as per my tables
  4. Last I tried to create a custom column with this query Security_Department = NOT(ISBLANK(LOOKUPVALUE(Roles[Departments],Roles[Departments],[Department],Roles[EMAIL],USERNAME())))

 

It still throws me error “ CUSTOMDATA, USERNAME and USERPRINCIPALNAME functions are not supported in calculated tables/columns. These functions may only be used in Measures or in the AllowedRowsExpression.”

 

Could anyone please provide me with a possible workaround for the error?

 

Thankyou In Advance

1 REPLY 1
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @adharia,

Please notice the issue have been asked on the comments of the article you posted. The author said:

 

Username() function can't be used in calculated column. So you should rather put the final formula into role row level filter directly.

Paste this expression into role definition and it will work

NOT(ISBLANK(LOOKUPVALUE(security_mapping[CATEGORY],security_mapping[CATEGORY],[Category],security_mapping[USER],USERNAME())))

When publishing to PowerBI.com

 NOT(ISBLANK(LOOKUPVALUE(security_mapping[CATEGORY],security_mapping[CATEGORY],[Category],security_mappi



The solution is not effective to you? Please review the first and second comments, please post feedback when you have still other problem.

Best Regards,
Angelia

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.