Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago

Hiding a column based on a user

Hi Folks,

 

Just trying to figure out something. There is a small population of users that I need to give access to the reports, but they are not allowed to see a performance rating column. Is there any way to hide this based on a group of users? 

 

So for example, if  Joe Employee logs in and he isn't supposed to see performance rating, how can I make it appear as 0 or N/A? 

 

Many thanks!!

19 Replies

  • you cannot hide column but you can hide the value, having said that, user can have access to the value if he knows how to do things in powerbi

     

     

  • I believe you're asking about hiding columns based on user role and privileges. For design mode we can simply hide the columns but that would be a static approach and surely can not be workable for a large number of users and roles. 

     

    I am investigating the same capabilities in Power BI and we know there is no such built-in feature in Power BI but I not 100% confident but I believe this could be achieved by following two ways:

     

    1. Customized Power BI Visual Development using TypeScript and Power BI REST API

    2. Dynamic data-source, even with dynamic OLAP cubes. (Performance could be a concern)

     

    I am working on Proof-of-Concept and would share my learning soon.

     

    • Ivo's avatar
      Ivo
      Frequent Visitor

      Hi smowais, please do as this is something that a lot of people are looking to do.

       

      Thanks,

      Ivo

    • Anonymous's avatar
      Anonymous
      Not applicable

      Good to know. Thanks!

  • Anonymous Try setting a role-based filter in power bi desktop before publishing to the cloud. Also, you can check using "view as role" before publishing.

     

      • Anonymous's avatar
        Anonymous
        Not applicable

        parry2k Is there a way to make it blank or with a "-" based on a user logged in? They only have read only access to the dashboards.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous,

     

    For your requirement, I'd like to suggest you to use query parameter to dynamic control the displayed columns.


    Steps:
    1. Create query parameter to store user name.
    2. Create mapping table with 'user name' and 'column name' 

    Sample:
    User, Columns
    abc, {"ColumnA","ColumnB"}
    bc, {"ColumnA","ColumnB","ColumnC"}
    Test, {"ColumnB"}

    3. Find out the specific table column names based on above user parameter, then use it as 'table name' parameter of Table.SelectColumns function.

     

    Reference links:

    Deep Dive into Query Parameters and Power BI Templates

    Table.SelectColumns


    BTW, I haven't found a way to pass 'username' to query editor, so it is impossible to create dynamic table based on username.

     

    Regards,

    Xiaoxin Sheng

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you. I will try this and see what happens. Much appreciated. 

      • parry2k's avatar
        parry2k
        Super User

        Anonymousyour solution is ok but if any of the field is used in report and is not available in data model based on user column selection, report will stop working, so I personally don;t think it is advisable to not to return the columns to the model , it is better to make multiple roles based on user and remove those columns. 

         

        Let me know if I missed something.

         

        So solution is to create calculated column and remove value from the column, it will break any report.