Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi, Trying to implement dynamic color scale type using parameter but it's working. Tryed all different ways using "expr' and "param". When I hard code quantile or linear it works. Please help. Below is my code...
{
"height": 400,
"data": {"name": "dataset"},
"params": [
{
"name": "Button",
"value": "quantile",
"bind": {
"input": "radio",
"options": [
"quantile",
"linear"
]
}
},
{
"name": "selectDate",
"select": {
"type": "interval",
"encodings": ["x"]
}
}
],
"layer": [
{
"mark": {
"type": "bar",
"stroke": "black",
"offset": 250
},
"encoding": {
"x": {
"bin": {
"maxbins": 220,
"minstep": 1
},
"field": "in Euro",
"type": "quantitative",
"axis": {
"orient": "top",
"title": null,
"offset": 0
}
},
"y": {
"aggregate": "count",
"axis": null,
"scale": {"reverse": true}
},
"color": {
"value": "lightgray",
"legend": null,
"condition": {
"test": {
"param": "selectDate"
},
"field": "in Euro",
"type": "quantitative",
"scale": {
"scheme": "spectral",
"type": {
"expr": "Button === 'quantile' ? 'quantile' : 'linear'"
}
}
}
},
"tooltip": {
"field": "Region",
"type": "nominal"
}
}
}
]
}
please provide sample data and complete sample code for the Deneb visual.
Above is my complete code and this is my sample data set.
Region | RegionCode | Variable | in Euro | Euro pro Nutzfläche |
Eisenstadt | 10101 | Gesamt | 4799.451948 | 7575 |
Rust | 10201 | Gesamt | 3012.695471 | 6930 |
Breitenbrunn | 10301 | Gesamt | 2024.605641 | 3349 |
Donnerskirchen | 10302 | Gesamt | 2558.893315 | 3308 |
Großhöflein | 10303 | Gesamt | 2274.977363 | 2342 |
Hornstein | 10304 | Gesamt | 1617.311349 | 884 |
Klingenbach | 10305 | Gesamt | 1057.198184 | 837 |
Leithaprodersdorf | 10306 | Gesamt | 2769.841692 | 1474 |
Mörbisch am See | 10307 | Gesamt | 2340.930157 | 8313 |
Müllendorf | 10308 | Gesamt | 1122.258437 | 1003 |
Neufeld an der Leitha | 10309 | Gesamt | 1297.191196 | 725 |
Oggau am Neusiedler See | 10310 | Gesamt | 2115.8991 | 2175 |
Oslip | 10311 | Gesamt | 1672.823362 | 1485 |
Purbach am Neusiedler See | 10312 | Gesamt | 2039.043158 | 5239 |
Sankt Margarethen im Burgenland | 10313 | Gesamt | 2733.814002 | 2317 |
Schützen am Gebirge | 10314 | Gesamt | 1691.339706 | 2857 |
Siegendorf | 10315 | Gesamt | 1684.918396 | 851 |
Steinbrunn | 10316 | Gesamt | 1209.040529 | 595 |
Surprisingly "type" does not allow expressions.
@dm-p surely that is an oversight? (or hopefully a misunderstanding on my part)
Whether it is an oversight or not, it is a design choice by the language authors - if you want this to be dynamic, I'd suggest creating an issue for Vega-Lite.
Proud to be a Super User!
My course: Introduction to Developing Power BI Visuals
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
User | Count |
---|---|
103 | |
88 | |
78 | |
71 | |
69 |
User | Count |
---|---|
113 | |
99 | |
97 | |
72 | |
68 |