Conditional Text in BloX Widget
Hello,
I'm still pretty new at BloX widgets, so hopefully this is a simple correction. I am trying to make a BloX widget have conditional text if a value is below another value, display text, else display another text. I am able to get the background color to change based upon that criteria, but not the text. Below is my code:
{
"style": "",
"script": "",
"title": "",
"showCarousel": true,
"carouselAnimation": {
"delay": 0
},
"conditions": [
{
"minRange": "-Infinity",
"maxRange": "{panel:DIR Company Avg}",
"backgroundColor": "#fd6e69"
},
{
"minRange": "{panel:DIR Company Avg}",
"maxRange": "Infinity",
"backgroundColor": "#3adcca"
}
],
"body": [
{
"spacing": "none",
"type": "Container",
"items": [
{
"spacing": "small",
"type": "TextBlock",
"class": "condition_data",
"text": "Your DIR score is {panel: DIR Score}",
"horizontalAlignment": "center",
"size": "large",
"weight": "bold",
"color": "white"
}
]
}
],
"conditionsTarget": [
{
"data-class": "condition_data",
"conditions": [
{
"minRange": "-Infinity",
"maxRange": "{panel:DIR Company Avg}",
"type": "TextBlock",
"text": "below avg"
},
{
"minRange": "{panel:DIR Company Avg}",
"maxRange": "Infinity",
"type": "TextBlock",
"text": "above avg"
}
]
}
]
}
Any help would be greatly appreciated! Thanks!
BDenman24
Posted 1 year ago·Last reply 1 year ago
4 comments
harikm007
·1 year agoHi BDenman24 ,
One solution is as follows:
Create a measure titled 'Is Above' that returns 1 if the value is "Above Avg" and 0 if it is "Below Avg." Your formula may look something like this:
Update the BloX script with the following:
Add the widget script to the BloX widget:
Here's the result:
Please let me know if this works for you.
Thanks,
Hari
https://www.binextlevel.com/
BDenman24
OP1 year agoThis works great! Thank yo so much Hari!
DRay
·1 year agoHi BDenman24,
Thank you for reaching out.
I found a few posts that may help. Can you take a look and let us know?
https://community.sisense.com/t5/build-analytics/use-of-conditions-in-blox/td-p/1574
https://community.sisense.com/t5/build-analytics/blox-conditional-formatting-up-and-down-indicators/m-p/3932
https://docs.sisense.com/main/SisenseLinux/sisense-blox-tutorials.htm
BDenman24
OP1 year agoThanks for the response! I tried a lot of the solutions you pointed out and nothing really solved my issue. However, Hari's solution below did! Thanks again!