0

Let's suppose I've got a simple table with two columns: user, value

Is it possible to use the function USERNAME within a code in order to filter the information that corresponds only to the user that is logged? Something like this:

Select username, value
from table 
where username = USERNAME()

And show only the information that every user should see.

Regards

Alexis Olson
  • 38,724
  • 7
  • 42
  • 64
d2907
  • 798
  • 3
  • 15
  • 45

1 Answers1

0

Yes, it's possible. You can use the USERNAME or USERPRINCIPALNAME as a filter in CALCULATE or as part of a Row Level Security filter.

Alexis Olson
  • 38,724
  • 7
  • 42
  • 64
  • Hi, I am new with this tool, I've been working with JasperSoft where I can use parameters in order to limit the information present in a report. For instance I can use the LogginUser within the where clause, and also the values of the filters before executing the code. If I understood, with power BI I have to execute all the query (without this condition) and then give visualization at row-level to the person that is using the report. Am I right? – d2907 Apr 07 '19 at 17:58
  • It depends on whether you're using Import or DirectQuery. Import will load all the rows in and then filter based on rules and DirectQuery essentially puts the filter in the WHERE clause sent back to the database. – Alexis Olson Apr 07 '19 at 21:03
  • Thanks Alexis for your reply. Unfortunately this option is not available for all the connections. In my case I am using Postgresql, that is why I was trying to look for a solution for my reports. – d2907 Apr 08 '19 at 02:04
  • If you can't use DirectQuery with Postgresql, then there is no way to do this without loading in the data for all users and then filtering via measures or RLS. It's simply not possible. – Alexis Olson Apr 08 '19 at 14:07