Forum Discussion
USERNAME() function DAX
I tried to use alternative as you said but have no success. I’ll try to explain my ideas as below though it is proved to be impossible.
I first create another table to store the users which need to be restricted access on Data.
Then create a measure to get the countries which should be shown for this login user. If the user is Twinster8, then China will be returned. If the user is others, then “” will be returned.
CountryShow =
VAR Country =
LOOKUPVALUE ( Table2[Country], Table2[Name], USERNAME () )
RETURN
( IF ( ISBLANK ( Country ), "", Country ) )
At last, try to create a calculated table to show the data of specified countries. I though it should be OK now but a "not supported" warning message returned.
("CUSTOMDATA and USERNAME functions are not supported in calculated columns. These functions may only be used in Measures or in the AllowedRowsExpression.")
A related idea can be found here.
FilterTable =
CALCULATETABLE (
Table1,
FILTER ( Table1, SEARCH ( [CountryShow], Table1[Country],, 0 ) > 0 )
)
So in my opinion, the only way to do it now is to use RLS with Pro License.
Best Regards,
Herbert
bad guys Dev team want more money and require pro license from all users who use this report