powerbipowerbi-embedded

Change Visual data field name for a powerbi embedded report


I have a powerbiembedded report. I need to change the data field in one of the visual of the report. I looked through the API but couldn't find one. Can Any one help me how can i can change the dispaly name using API.


Solution

  • setDataFieldDisplayName can be used to change the data field of the visual.

    1. Get the data field display name of the visual. This methods take two variables as parameters. dataRole and index.
    const oldDisplayName = await lastCreatedVisual.getDataFieldDisplayName('Y', 0);
    
    1. Use the API to change the data field of the visual. This methods take three variables as parameters. dataRole, index and newDisplayName.
    const newDisplayName = "NEW_DISPLAY_NAME"; // New DisplayName to be Updated 
    await lastCreatedVisual.setDataFieldDisplayName('Y', 0, newDisplayName)
    

    References: Visual Descriptor SetDataFieldDisplayName