Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi,
Pure begginer here on vega-lite code. I have a code written by Daniel , one of the creators of Deneb. I'm trying to replicate the code by adding my own measures such as "Sales Volume", "Gross Profit" and "Region" instead of "No of Responses" , "NPS Score" & "Location".
I've tried replacing the values to fit my new measures. But what i've noticed is that the chart turns blank. and shows no values..
Hope someone can bring some light to this..
{
"data": {"name": "dataset"},
"transform": [
{
"stack": "No of Responses",
"sort": [
{
"field": "NPS Score",
"order": "descending"
}
],
"as": ["v1", "v2"],
"groupby": []
},
{
"calculate": "datum['v2'] - ((datum['v2'] - datum['v1']) / 2)",
"as": "category_mid"
}
],
"encoding": {
"x": {
"type": "quantitative",
"axis": null
},
"y": {
"type": "quantitative",
"axis": {"title": null},
"scale": {
"domain": [-100, 100],
"range": [
{"expr": "height - 40"},
0
]
}
},
"tooltip": [
{
"field": "Location",
"type": "nominal"
},
{
"field": "NPS Score",
"type": "quantitative",
"formatType": "pbiFormat",
"format": "#"
},
{
"field": "No of Responses",
"type": "quantitative"
}
]
},
"layer": [
{
"mark": {
"type": "bar",
"tooltip": true
},
"encoding": {
"x": {"field": "v1"},
"x2": {"field": "v2"},
"y": {"field": "NPS Score"},
"y2": {"datum": 0},
"color": {
"condition": [
{
"test": "datum['NPS Score'] <= 0",
"value": "#FF4400"
}
],
"value": "#3AD11F"
}
}
},
{
"mark": {"type": "text", "baseline": "bottom"},
"encoding": {
"x": {"field": "category_mid"},
"y": {"value": {"expr": "height - 15"}},
"text": {"field": "Location"}
}
},
{
"mark": {"type": "text", "baseline": "bottom"},
"encoding": {
"x": {"field": "category_mid"},
"y": {"value": "height"},
"text": {"field": "No of Responses"}
}
},
{
"transform": [
{
"calculate": "datum['NPS Score'] / 2",
"as": "y_midpoint"
}
],
"mark": {
"type": "text",
"color": "black"
},
"encoding": {
"text": {
"field": "NPS Score",
"formatType": "pbiFormat",
"format": "#"
},
"x": {"field": "category_mid"},
"y": {"field": "y_midpoint"}
}
}
]
}
BR
Hi @Jared__ ,
Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
User | Count |
---|---|
81 | |
79 | |
71 | |
70 | |
54 |
User | Count |
---|---|
107 | |
99 | |
88 | |
79 | |
67 |