This discussion addresses how to display a compliance percentage in a ControlUp dashboard card based on two widget values: total devices and compliant devices. The goal is to calculate and show a compliance rate as a percentage, for example, showing 5% if 10 out of 200 devices are compliant. The solution involves using the ControlUp JSON builder with a custom query and transformation setup.
To achieve this, the key is to use the “CombineMetrics” plugin in the JSON configuration. This plugin allows the calculation of a ratio (a percentage) by specifying the compliant devices count as the numerator and the total devices count as the denominator. Participants shared examples modeled after an AI dashboard where a similar percentage metric—percentage of users accessing AI-related websites—is calculated by summing durations and using filters.
One example query includes the use of “cardinality” aggregation on device IDs, filtering by device groups and OS details to separately count total devices and compliant ones. This data is then fed into a transformation block that scales the ratio by 100 and applies precision to display the percentage nicely. The JSON snippet demonstrates how the numeratorNodeIds and denominatorNodeIds correspond to the compliant and total device counts, respectively, providing a ready-to-adapt template.
Additionally, the conversation touched on the potential for applying conditional palette colors to the percentage display, similar to gauges, to visually represent thresholds (e.g., red for 0%, orange at 50%, green at 100%). Though not yet implemented, this idea is being considered as part of ongoing UI improvements.
For further implementation guidance, ControlUp documentation on custom widgets and the JSON query builder is a useful resource at https://docs.controlup.com. The approach described can support not only two values but can be extended to combine multiple metrics as needed, providing flexible compliance and performance monitoring visualizations in ControlUp dashboards.
Read the entire ‘How to Calculate and Display Compliance Percentage Using ControlUp JSON Query and Transformations’ thread below:
Maybe a stupid question.. but I want to achieve the following: I want to display the compliance percentage based on two widgets: Total Devices and Compliant Devices. For example, if there are 200 total devices and 10 compliant devices, the card should display a compliance rate of 5%.
How can I get this working?
You can do this in the json builder
If you need an example look at the AI dashboard and look at the percentage of users using website ai.
Hero!! I will do it tomorrow thnx!
“`{
“queryConfigs”: [
{
“version”: “1.0”,
“dataSource”: {
“product”: “edge”,
“entity”: “url_domains”
},
“query”: {
“select”: [],
“groupBy”: [],
“aggregates”: [
{
“fn”: “sum”,
“metric”: “duration_ms”,
“as”: “tot_web”
},
{
“fn”: “sum”,
“metric”: “duration_ms”,
“as”: “sum_ai_web”,
“filters”: {
“or”: [
{
“metric”: “domain”,
“op”: “contains”,
“value”: “chatgpt.com“
},
{
“metric”: “domain”,
“op”: “contains”,
“value”: “copilot.microsoft.com“
},
{
“metric”: “domain”,
“op”: “contains”,
“value”: “deepseek*”
},
{
“metric”: “domain”,
“op”: “contains”,
“value”: “gemini“
},
{
“metric”: “domain”,
“op”: “contains”,
“value”: “openai“
},
{
“metric”: “domain”,
“op”: “contains”,
“value”: “claude*”
}
]
}
}
],
“sort”: []
}
}
],
“transformations”: [
{
“id”: “cmb_ai_percent_web”,
“config”: {
“scale”: 100,
“precision”: 2,
“numeratorNodeIds”: [
“sum_ai_web”
],
“denominatorNodeIds”: [
“tot_web”
]
},
“plugin”: “CombineMetrics”,
“sourceIds”: [
“sum_ai_web”,
“tot_web”
]
}
]
}“`
here you can see the code that we have a transformation for percentage between 2 values
it can even work with 4 values
you’re the best! It’s working fine!
“`{
“queryConfigs”: [
{
“version”: “1.0”,
“dataSource”: {
“product”: “edge”,
“entity”: “_devices”
},
“query”: {
“select”: [],
“groupBy”: [],
“aggregates”: [
{
“fn”: “cardinality”,
“metric”: “_device_id”,
“as”: “tot_devices”,
“filters”: {
“and”: [
{
“metric”: “tags”,
“op”: “eq”,
“value”: “{{Autopatch Group}}”
},
{
“metric”: “group”,
“op”: “eq”,
“value”: “{{Customer}}”
},
{
“metric”: “os_name”,
“op”: “contains”,
“value”: “Microsoft Windows *”
}
]
}
},
{
“fn”: “cardinality”,
“metric”: “_device_id”,
“as”: “comp_devices”,
“filters”: {
“and”: [
{
“metric”: “os_version_string”,
“op”: “gte”,
“value”: “{{Target Version}}”
},
{
“metric”: “tags”,
“op”: “eq”,
“value”: “{{Autopatch Group}}”
},
{
“metric”: “group”,
“op”: “eq”,
“value”: “{{Customer}}”
},
{
“metric”: “os_name”,
“op”: “contains”,
“value”: “Microsoft Windows *”
}
]
}
}
],
“sort”: []
}
}
],
“transformations”: [
{
“id”: “cmb_ai_percent_web”,
“config”: {
“scale”: 100,
“precision”: 1,
“numeratorNodeIds”: [
“comp_devices”
],
“denominatorNodeIds”: [
“tot_devices”
]
},
“plugin”: “CombineMetrics”,
“sourceIds”: [
“comp_devices”,
“tot_devices”
]
}
]
}“`
awesome! thats great
Thnx for your help! Another question: will it be possible to do some Palette colors based on threshold? Just the same as we can do with a Gauge. For example 0% is red, 50% will be orange and for 100% green.
We are reworking colors! Its a good idea
Continue reading and comment on the thread ‘How to Calculate and Display Compliance Percentage Using ControlUp JSON Query and Transformations’. Not a member? Join Here!
Categories: All Archives, ControlUp Dashboards
