Querying Model in Text Widgets?
Is it possible to query your model in a text widget to display a value?
For example say I have a text widget that says Total Revenue: {Total Revenue} this part coming from your model?
I know this can be achieved in BloX but BloX does not work with Compose SDK so I am trying to see if this works in a text widget.
Rafael Ferreira
Posted 9 months ago·Last reply 9 months ago
5 comments
harikm007
·9 months agoHi
As you know, the Text widget in Sisense doesn’t allow adding dimensions or measures directly, so there’s no built-in way to display dynamic values like {Total Revenue} out of the box. However, this can be achieved using a small custom script.
Here’s one approach you can try:
Create a Text Widget and add your desired text in the widget, for example: This year revenue: {Total Revenue}.
We’ll use a script to replace {Total Revenue} with the actual value from your model.
Add the following script to your widget:
Replace the value of textToReplace with the placeholder text you want to replace in your widget.
In the script above, replace the query object with the JAQL you want to execute.
If you need to use a more complex calculation, you can get the exact JAQL by creating a temporary Indicator Widget and adding your formula in the Primary panel.
Then, in your browser console, run: prism.activeWidget.metadata.panels[0].items[0].jaql
Copy the JAQL object from the console output and use it in query variable in the script.
Then, save the script and refresh the dashboard.
Result:
If you prefer a simpler, no-code approach, you can use the Paldi Advanced Text Widget plugin.
It allows you to:
- Add rich text, images, and HTML content
- Display dynamic values and dimensions directly
- Avoid custom scripting
This is often the most efficient and flexible solution for dynamic text in dashboards.
https://www.paldi.solutions/sisense-plugins/advanced-text-widget
Please let me know if you have any questions
-Hari
Liliia Kislitsyna
Admin9 months agoAstroraf Hi 🙃,
According to our dev team, there is no need to query data inside a text widget. Instead, load the data with a separate useExecuteQuery hook (example on playground). You can also render this data in any format anywhere on the page. If you need to inject a new widget to the existing dashboard on the fly, you can add a new widget (e.g., TextWidget with a static data-string) like in this example.
Even a better option is to create your own custom widget (example) with any data visualization you need. CustomWidget is a much more powerful and flexible solution and is a direct replacement for the BloX plugin in the Sisense native application.
Hope that helps!
Rafael Ferreira
OP9 months agoHi Liliia_DevX
But if I am just embeeding Sisense dashboard via Dashboard ID or by Widget ID, then is there a way to query the data in a text field box?
Liliia Kislitsyna
Admin9 months agoAstroraf Thanks for your reply. What do you mean by embedding in this case? Please describe your use with ComposeSDK to provide you with the proper suggestions.
Rafael Ferreira
OP9 months agoHey harikm007 since you are such a wise wizard, do you know if this is plausible in Sisense?