Forum Discussion

lwgpowerbiadmin's avatar
lwgpowerbiadmin
Frequent Visitor
4 years ago

Creating report with Dynamic fields

Hi,

Our application is a multi tenancy web app and we are using Custom fields for User table based on the client. Each client can have upto 8 custom fields in which they can define the name for that custom fields. So in In reports (table or matrix) we would like to display the custom field value in header. Please find our use case below. Columns which are marked in Blue color are static columns.

 

 

 

Please help us to resolve this issue.

 

Thanks in advance

Madhan

3 Replies

Replies have been turned off for this discussion
  • Hi lwgpowerbiadmin ,

    This can be done in Power Query. You need to maintain a table that contains the columns to be renamed and the new names.  These columns in a table will be converted to a list of lists which will be used in the Table.Renames argument in the  other table instead of hardcoding the new names. Instead of something like this:

    = Table.RenameColumns(#"Changed Type",{{"Custom1", "Male"}, {"Custom2", "Email"}, {"Custom3", "Country"}})

     

    you do this:

    = Table.RenameColumns(#"Changed Type", Names)

     

    Here's the link to the sample pbix. Go to the query editor to see the M script. https://drive.google.com/file/d/1iH9LHZkX4OVpfW788_81dGwCEiiMMo1G/view?usp=sharing 

    • lwgpowerbiadmin's avatar
      lwgpowerbiadmin
      Frequent Visitor

      Hi danextian 

       

      Thnaks a lot for your solutions. This helps us to move further. But we are facing issue while changing the Names list value. Please see below scenario

       

      Names list:

      Initially we have mapped names like below

      Custom1: Gender

      Custom2: Email

      Custom3: Country

      with this list we have creted Table Visual and it is working perfect.

       

      Now to simulate the same report for another Client, We have changed the List value (Email to EmailAddress)

      Custom1: Gender

      Custom2: EmailAddress

      Custom3: Country

       

      When we close and apply, we are getting below error in Table visual.

       

       

      Basically we are using Embedded Report in our report for all our clients. based on the client Names list will change. Please guide us on this.

       

       

       

       

      • danextian's avatar
        danextian
        Super User

        hI lwgpowerbiadmin,

        I couldn't replicate your error when trying to change the column name manually but did so after modifying the column names mapping which in turn automatically renamed the Email column to  EmailAddress.
        It seems that "automatically" renaming a column can cause an error in the visual that uses the original column name.  The simplest solution is to remove that erring column/field and replace it with what it's been renamed to.