Forum Discussion

Guneet_B21's avatar
Guneet_B21
Icon for Helper II rankHelper II
4 years ago
Solved

Change Data according to user

Hi,

i am providing BI reports to multiple customers with the same template and database,

right now duplicating the file for each customer and chaging the filter;

 

Is there a way to publish only 1 report which filter can change according to the user's login?

  • Guneet_B21 

     

    Not sure about your data set but you can make use of RLS, below you can see that how you can change the filter according to Login , for example Worker should only see Internal 

     

    Consider an example using Power BI embedded, where the app passes the user's job role as the effective user name: It's either "Manager" or "Worker". Managers can see all rows, but workers can only see rows where the Type column value is "Internal".

    The following rule expression is defined:

    DAXCopy
     
    IF(
        USERNAME() = "Worker",
        [Type] = "Internal",
        TRUE()
    )

    The problem with this rule expression is that all values, except "Worker", return all table rows. So, an accidental value, like "Wrker", unintentionally returns all table rows. Therefore, it's safer to write an expression that tests for each expected value. In the following improved rule expression, an unexpected value will result in the table returning no rows.

    DAXCopy
     
    IF(
        USERNAME() = "Worker",
        [Type] = "Internal",
        IF(
            USERNAME() = "Manager",
            TRUE(),
            FALSE()
        )
    )

    For more information check here >> Row-level security (RLS) guidance in Power BI Desktop - Power BI | Microsoft Docs

    Regards,
    Ritesh

     

     

2 Replies

  • Guneet_B21 

     

    Not sure about your data set but you can make use of RLS, below you can see that how you can change the filter according to Login , for example Worker should only see Internal 

     

    Consider an example using Power BI embedded, where the app passes the user's job role as the effective user name: It's either "Manager" or "Worker". Managers can see all rows, but workers can only see rows where the Type column value is "Internal".

    The following rule expression is defined:

    DAXCopy
     
    IF(
        USERNAME() = "Worker",
        [Type] = "Internal",
        TRUE()
    )

    The problem with this rule expression is that all values, except "Worker", return all table rows. So, an accidental value, like "Wrker", unintentionally returns all table rows. Therefore, it's safer to write an expression that tests for each expected value. In the following improved rule expression, an unexpected value will result in the table returning no rows.

    DAXCopy
     
    IF(
        USERNAME() = "Worker",
        [Type] = "Internal",
        IF(
            USERNAME() = "Manager",
            TRUE(),
            FALSE()
        )
    )

    For more information check here >> Row-level security (RLS) guidance in Power BI Desktop - Power BI | Microsoft Docs

    Regards,
    Ritesh