Let’s consider a use case where a developers wants to develop a visual where the either requires no data, or requires data that will be pulled in from a source that isn’t a Power BI field well.
Consider the following use cases:
- External Source:
This can be any data source from a SQL Server to a REST API. - Format Pane:
The data is fetched from the inputs added by the user in the Format Pane. For Eg: A video link to render a video in your visual - Visual Input:
The data is either uploaded or typed in within the visual itself - No Data:
The visual may require absolutely no data.
By default, the Power BI Custom Visual framework enforces a user to add a field to the visual. An error message is shown when a Custom Visual is added to the report without and data. There is another drawback where the Formatting Pane is disabled when no data is added.
Fortunately, there is a workaround to avoid this and to make a Custom Visual work, even when there isn’t any data populated. Following is the code that needs to be added in capabilities.json file.
{
"supportsLandingPage": true,
"supportsEmptyDataView": true,
}
supportsLandingPage enables a developer to add content in the visual even when there isn’t any data added.
supportsEmptyDataView allows Power BI to update the visual successfully even when there isn’t any data added to the visual.
This is all that needs to be done for a visual to work without any data!