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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
JordanBieber
Frequent Visitor

Compare rows to measure to display records based on user

My goal is to provide a function for users to instantly filter for rows related to them, based on the UserName()

First step was to make a Measure:

CurrentUser = UserName()


From here, I would like to do a comparison on another table to have a column that indicates whether or not the row is "related to the person" if a field contains their user id. Such as:

ThisIsMe = IF(ISERROR(SEARCH([CurrentUser], 'DATATABLE'[OwnerID])),"No","Yes")

 

I cannot create this as a column, I get:
<!> CUSTONDATA, USERNAME AND USERPRINCIPALNAME functions are not supported in calculated tables/columns. These functions may only be used in Measures or in the AllowedRowsExpression.

 

I can create it as a Measure if I add MAX function around the table data...

ThisIsMe = IF(ISERROR(SEARCH([CurrentUser], MAX('DATATABLE'[OwnerID]))),"No","Yes")

but I cannot use this measure for much, not even in a slicer.

Any good ideas on how to compare the UserName() value to text in your data tables(and make that comparison usable)?

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @JordanBieber,

 

You can try to use below formula to check username:

IsMe = IF(CONTAINS(VALUES(Sheet2[Login]),[Login],USERNAME()),"Yes","No")

1.PNG2.PNG

 

In addition, if you want to use username function to dynamic filter records, I'd like to suggest you use RLS with usernam.

 

Reference:

Dynamic Row Level Security with Power BI Made Simple

 

Regards,

Xiaoxin Sheng

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

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @JordanBieber,

 

You can try to use below formula to check username:

IsMe = IF(CONTAINS(VALUES(Sheet2[Login]),[Login],USERNAME()),"Yes","No")

1.PNG2.PNG

 

In addition, if you want to use username function to dynamic filter records, I'd like to suggest you use RLS with usernam.

 

Reference:

Dynamic Row Level Security with Power BI Made Simple

 

Regards,

Xiaoxin Sheng

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

You won't be able to do this by creating a column, as those values are calculated when the data is refreshed.  Thus it was be person independant.  What you will need to do is make use of a calculate statement.  How about something like this?

My Measure = 
VAR MyName = 'Your Table'[CurrentUser]
RETURN
Calculate(
	<Thing you want the measure to show>,	
	'Your Table'[OwnerUserName] = MyName
)

 

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors