How to resolve the issue "no data to display" when filtering in embedding application?
Handling Dashboard Parameters in BoldBI
When working with BoldBI, it’s important to understand how to properly handle dashboard parameters. This is especially true when embedding dashboards, as incorrect handling can lead to issues such as no data being displayed with an error message no data to display
.
Understanding the Issue
In some cases, you may find that your dashboard is not displaying any data when you pass certain parameters. This issue often arises when the column name and its corresponding dashboard parameter name are identical.
When you pass filter values via the “filterParameters” API in the embedding application, these values are interpreted as the column name. This can lead to a “no data to display” message in the widgets.
Solution
To resolve this issue, it is recommended to alter the dashboard parameter name and execute your filtering through the embedding.
Example
- When you have a database similar to the below one and configured in Bold BI with the below Query,
Id | EmpName |
---|---|
1 | John |
2 | Brito |
3 | Fedrick |
SELECT Id, EmpName FROM Employee WHERE Id = CASE WHEN @{{:Id}} = 0 THEN Id ELSE @{{:Id}} END OR EmpName = @{{:EmpName}}
Here, I have created dashboard parameters Id
and EmpName
with the respective default values 0
and -
.
- When I try to perform filtering through the
filterParameters
API with below values,
filterParameters:"Id=1 & EmpName=Fedrick",
Then we will get an error in an embedded dashboard as “no data to display”. So to resolve this either we can change the dashboard parameters name other than the respective column name or if we want to filter using the column name and display both values as expected in Bold BI, we can use the value “filterParameters: Id=1|| EmpName=Brito” in the BoldBI.create() method. This is because we’ve included the “OR” condition in our data connection query.
- We can utilize the below code to filter using column name instead of dashboard parameter,
filterParameters:"Id=1 || EmpName=Fedrick",
By following these steps, we should be able to successfully pass parameters and display data in our embedded dashboard.
References
- BoldBI Documentation: Embedding Dashboards
- BoldBI Documentation: Working with Dashboard Parameters
Please note that this article may not cover all possible scenarios. Always refer to the official BoldBI documentation for the most accurate and up-to-date information.