Forum Discussion

rohann's avatar
rohann
Regular Visitor
4 months ago
Solved

Using getDataFieldDisplayName for Field Paramter does not return correct values

I am trying to extract the display names of the fields being used in a visual from a Power BI embed. I am using the getDataFieldDisplayName function from the power bi authoring library. However this does not seem to work correctly on Field Parameters. 
In the first instance (Image #1) I have dragged a field parameter into a table visual. When i get the datafields in the table visual I can see all the currently selected fields activated by the slicer. But when i try to fetch the displayNames for those fields it returns correctly for the first field but throws an undefined error for the rest.


In a second instance (Image #2)
I have added two fields "Currency" and "FileType" from the Field parameter and a third field "File Name" directly from the model (not from the field parameter). In this case File Name is being returned as the display name for the second "File Type" field. 

Could someone please explain this behaviour or suggest any alternative methods to get the display names of the fields accurately. 

Image #1Image #2 

 

  • Hi rohann,

    Thank you  for reaching out to the Microsoft fabric community forum.


    Field Parameters are dynamic, so they don’t behave like normal columns. Because of that, getDataFieldDisplayName is not able to correctly return the display name for all the fields coming from the parameter.

    That’s why you are seeing First field name coming correctly, but others showing undefined and When mixing parameter fields with a normal column, the display name getting mapped incorrectly

    So the issue is not with your code. It happens because the API reads static metadata, while Field Parameters switch fields dynamically at runtime. For now, you may need to rely on the information from getDataFields() and handle the display name mapping manually on your side.

    Hope the above provided information help you resolve the issue, if you have any further concerns or queries, please feel free to reach out to us.
    Regards,
    Community Support Team.

5 Replies

  • v-hjannapu's avatar
    v-hjannapu
    Community Support

    Hi rohann,

    Thank you  for reaching out to the Microsoft fabric community forum.


    Field Parameters are dynamic, so they don’t behave like normal columns. Because of that, getDataFieldDisplayName is not able to correctly return the display name for all the fields coming from the parameter.

    That’s why you are seeing First field name coming correctly, but others showing undefined and When mixing parameter fields with a normal column, the display name getting mapped incorrectly

    So the issue is not with your code. It happens because the API reads static metadata, while Field Parameters switch fields dynamically at runtime. For now, you may need to rely on the information from getDataFields() and handle the display name mapping manually on your side.

    Hope the above provided information help you resolve the issue, if you have any further concerns or queries, please feel free to reach out to us.
    Regards,
    Community Support Team.

    • rohann's avatar
      rohann
      Regular Visitor

      Thanks for the prompt reply.
      Is this some kind of documented limitation? Since I did not find any. Or is this just found by exploration. 

      • v-hjannapu's avatar
        v-hjannapu
        Community Support

        Hi rohann,

        Thank you for reaching out to the Microsoft Community Forum.

        No, there isn't any official Microsoft documentation that explicitly states this as a limitation. I simply observed it from my understanding and working knowledge of how Field Parameters work they are resolved dynamically at runtime and how the authoring APIs operate (they rely on static metadata).

        Regards,
        Community Support Team.