Forum Discussion

Aksha_poojari's avatar
Aksha_poojari
New Member
2 years ago
Solved

powerbi custom theme for stacked bar graph using json file

How we can create the custom theme for stacked bar graph using json file which include the conditional rule. i used the below code to achive the same but it's throwin error as error while importing the json file. Looks like conditional format is not supported here? it should be done manually?

"barChart": {
"*": {
"dataPoint": {
"fill": {
"solid": {
"color": {
"$expr": "d => {
if (d.value <= 20) return '#ED9AA1';
else if (d.value <= 40) return '#E77881';
else if (d.value <= 60) return '#E15662';
else if (d.value <= 80) return '#B4454E';
else return '#87343B';
}"
}
}
}
}
}
}

  • Hi Aksha_poojari - In Power BI does not support conditional formatting directly in the JSON theme file, you can define colors in a JSON file and then apply the conditional formatting rules on the top of it using conditions manually through the Power BI interface. 

     

    create a measure calcuation and define the conditional formatting as per your requirement.

     

     

    Hope the above information helps you.

     

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!!

     

2 Replies

  • Hi Aksha_poojari - In Power BI does not support conditional formatting directly in the JSON theme file, you can define colors in a JSON file and then apply the conditional formatting rules on the top of it using conditions manually through the Power BI interface. 

     

    create a measure calcuation and define the conditional formatting as per your requirement.

     

     

    Hope the above information helps you.

     

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!!