We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
I’m new to Deneb and haven’t been able to figure out how to color this heatmap so that it is colored by row, or category, rather than as a whole:
I want the rows to be color independently of one another, like this:
This is my first forum post and I don't see a way to post a .pbix. Here is the Deneb specification using Vega Lite:
{
"data": {"name": "dataset"},
"mark": {
"type": "rect",
"stroke": "white",
"tooltip": true
},
"encoding": {
"y": {
"field": "Category",
"type": "nominal",
"title": "",
"axis": {
"domain": false,
"ticks": false,
"labels": true,
"labelAngle": 0,
"labelPadding": 5
}
},
"x": {
"field": "Date",
"type": "ordinal",
"title": "",
"timeUnit": "yearmonth",
"axis": {
"domain": false,
"ticks": false,
"labels": true,
"labelAngle": -90,
"orient": "top"
}
},
"tooltip": [
{
"field": "Category",
"type": "nominal"
},
{
"field": "Date",
"type": "ordinal"
},
{
"field": "Growth (MoYaM)",
"type": "quantitative",
"format": ".1%"
},
{
"field": "Growth (WDC)",
"type": "quantitative",
"format": ".1%"
}
],
"color": {
"aggregate": "max",
"field": "Growth (WDC)",
"type": "quantitative",
"title": "Growth (WDC)",
"scale": {
"scheme": "pbiColorDivergent"
},
"legend": {
"direction": "vertical",
"gradientLength": 120,
"format": ".1%"
}
}
}
}
Any help is greatly appreciated. Thanks.
Solved! Go to Solution.
@Doug7983, I see the issue. I had a rogue closed bracket in the data object that I missed. I deleted it and updated the above spec. Try it now.
"data": {
"name": "dataset"
] //<-- Should not be there
}
Another great catch @Doug7983. That's what I get for trying to rush through it 😆
gist
{
"transform": [
{"calculate": "(month(datum['Date'])+1)", "as": "monthNum"},
{
"calculate": "datum['monthNum'] + (datum['monthNum'] < 7 ? 6 : -6)",
"as": "monthSort"
},
{
"calculate": "'FY ' + toString(year(datum['Date']) + (datum['monthSort'] <= 6 ? +1 : 0))",
"as": "FY"
}
],
"facet": {
"column": {"field": "FY", "title": null, "header": {"labelFontSize": 13}}
},
"resolve": {"scale": {"x": "independent"}},
"spacing": {"column": 5},
"spec": {
"width": {"step": 30},
"mark": {"type": "rect", "stroke": "white", "tooltip": true},
"encoding": {
"x": {
"field": "Date",
"type": "ordinal",
"title": null,
"timeUnit": "month",
"axis": {
"domain": false,
"ticks": false,
"labels": true,
"labelOpacity": 0.65,
"orient": "top"
},
"sort": {"field": "monthSort"}
},
"y": {
"field": "Category",
"type": "nominal",
"title": "",
"axis": {
"domain": false,
"ticks": false,
"labels": true,
"labelOpacity": 0.65,
"labelAngle": 0,
"labelPadding": 5
}
},
"tooltip": [
{"field": "Category", "type": "nominal"},
{"field": "Date", "type": "temporal"},
{"field": "Growth (MoYaM)", "type": "quantitative", "format": ".1%"},
{"field": "Growth (WDC)", "type": "quantitative", "format": ".1%"}
],
"color": {
"aggregate": "max",
"field": "Growth (WDC)",
"type": "quantitative",
"title": "Growth (WDC)",
"scale": {"domainMid": 0, "reverse": true, "scheme": "blueorange"},
"legend": {
"titleBaseline": "bottom",
"direction": "vertical",
"format": ".1%",
"orient": "right"
}
}
}
},
"data": {
"name": "dataset"
}
}
Thanks for the dataset, @Doug7983. Let me know if something like this scratches the itch.
Here is a gist that contains the spec. I've also included it below.
{
"resolve": {"scale": {"color": "independent"}},
"facet": {
"row": {
"field": "Category",
"header": {"labelAngle": 0, "labelAlign": "left"},
"title": null
}
},
"spacing": -5,
"spec": {
"mark": {"type": "rect", "stroke": "white", "tooltip": true},
"encoding": {
"x": {
"field": "Date",
"type": "ordinal",
"title": null,
"timeUnit": "yearmonth",
"axis": {
"domain": false,
"ticks": false,
"labels": true,
"labelAngle": -90,
"orient": "top"
}
},
"tooltip": [
{"field": "Category", "type": "nominal"},
{"field": "Date", "type": "ordinal"},
{"field": "Growth (MoYaM)", "type": "quantitative", "format": ".1%"},
{"field": "Growth (WDC)", "type": "quantitative", "format": ".1%"}
],
"color": {
"aggregate": "max",
"field": "Growth (WDC)",
"type": "quantitative",
"title": "Growth (WDC)",
"legend": {
"direction": "horizontal",
"title": null,
"gradientLength": 120,
"format": ".1%",
"labelOffset": {"expr": "-child_height*0.6"},
"labelColor": {
"expr": "luminance(scale('child_color', max(0, parseFloat(datum.label)/100))) < 0.5 ? '#fff' : '#000'"
}
}
}
}
},
"data": {
"name": "dataset"
}
}
}
This is helpful, thank you. For context, I'm a long-time Tableau user and relatively new to both Power BI and Deneb. I have found it challenging to accurately describe what I'm trying to accomplish, so please bear with me.
Example (and screenshot below):
My data has a range of -12.4% to 64.8%:
The deepest blue will always correspond to the highest value in the data set, regardless of row.
The deepest orange will always correspond to the lowest value in the data set, regardless of row.
The spectrum of color is applied such that a particular shade of blue, for example, will represent the same value, no matter where it appears. Same for shades of orange and everything in between. I’ve added labels here to see if maybe that helps:
Aside from all that, a question: I see in your spec that you are declaring the range of values. My data changes every day, so that wouldn't be practical. Is there a way to avoid that and have the range be dynamic?
Thanks,
Doug
Hey @Doug7983. Welcome to the forums! That's awesome that you're diving into Deneb. Thank you for providing your spec and screenshots. Here's how to provide a .pbix, which would be very helpful. Alternatively, if you're able to provide a sanitized dataset that matches your schema, that will also work.
Happy to try to help once I have either the dataset or .pbix.
Thanks for the reply, @giammariam. Security policies prevent me from uploading a .pbix as described in your linked instructions, and character limitations prevent pasting the full file here. I'm attempting to paste in a partial data set.
| Date | Category | Growth (WDC) | Growth (MoYaM) |
| 11/1/21 | Category 01 | 23.2% | 29.7% |
| 12/1/21 | Category 01 | 11.9% | 11.9% |
| 1/1/22 | Category 01 | 12.9% | 18.9% |
| 2/1/22 | Category 01 | 9.1% | 9.1% |
| 3/1/22 | Category 01 | 20.8% | 20.8% |
| 4/1/22 | Category 01 | 29.3% | 23.5% |
| 5/1/22 | Category 01 | 35.6% | 42.7% |
| 6/1/22 | Category 01 | 27.6% | 27.6% |
| 7/1/22 | Category 01 | 42.4% | 13.9% |
| 8/1/22 | Category 01 | 27.7% | 33.5% |
| 9/1/22 | Category 01 | 17.7% | 23.6% |
| 10/1/22 | Category 01 | 18.7% | 18.7% |
| 11/1/22 | Category 01 | 9.0% | 9.0% |
| 12/1/22 | Category 01 | 14.4% | 14.4% |
| 1/1/23 | Category 01 | 10.1% | 10.1% |
| 2/1/23 | Category 01 | 8.5% | 8.5% |
| 3/1/23 | Category 01 | 13.0% | 13.0% |
| 4/1/23 | Category 01 | 6.0% | 0.9% |
| 5/1/23 | Category 01 | 3.0% | 13.3% |
| 6/1/23 | Category 01 | 6.9% | 6.9% |
| 7/1/23 | Category 01 | 11.8% | 11.8% |
| 8/1/23 | Category 01 | 13.8% | 13.8% |
| 9/1/23 | Category 01 | 17.6% | 12.0% |
| 10/1/23 | Category 01 | 14.5% | -61.8% |
| 11/1/21 | Category 03 | 15.2% | 21.3% |
| 12/1/21 | Category 03 | 10.6% | 10.6% |
| 1/1/22 | Category 03 | 14.2% | 20.2% |
| 2/1/22 | Category 03 | 12.4% | 12.4% |
| 3/1/22 | Category 03 | 12.2% | 12.2% |
| 4/1/22 | Category 03 | 13.5% | 8.3% |
| 5/1/22 | Category 03 | 15.5% | 21.5% |
| 6/1/22 | Category 03 | 6.5% | 6.5% |
| 7/1/22 | Category 03 | 17.9% | -5.7% |
| 8/1/22 | Category 03 | 7.7% | 12.6% |
| 9/1/22 | Category 03 | -1.7% | 3.2% |
| 10/1/22 | Category 03 | 8.0% | 8.0% |
| 11/1/22 | Category 03 | 12.3% | 12.3% |
| 12/1/22 | Category 03 | 6.7% | 6.7% |
| 1/1/23 | Category 03 | 4.0% | 4.0% |
| 2/1/23 | Category 03 | 8.4% | 8.4% |
| 3/1/23 | Category 03 | 18.8% | 18.8% |
| 4/1/23 | Category 03 | 14.0% | 8.6% |
| 5/1/23 | Category 03 | 5.2% | 15.7% |
| 6/1/23 | Category 03 | 12.7% | 12.7% |
| 7/1/23 | Category 03 | 8.7% | 8.7% |
| 8/1/23 | Category 03 | 10.5% | 10.5% |
| 9/1/23 | Category 03 | 5.8% | 0.8% |
| 10/1/23 | Category 03 | 1.7% | -66.1% |
| 11/1/21 | Category 10 | 24.0% | 30.5% |
| 12/1/21 | Category 10 | 15.8% | 15.8% |
| 1/1/22 | Category 10 | 11.8% | 17.7% |
| 2/1/22 | Category 10 | 11.3% | 11.3% |
| 3/1/22 | Category 10 | 18.3% | 18.3% |
| 4/1/22 | Category 10 | 21.6% | 16.1% |
| 5/1/22 | Category 10 | 14.6% | 20.6% |
| 6/1/22 | Category 10 | 12.5% | 12.5% |
| 7/1/22 | Category 10 | 25.4% | 0.3% |
| 8/1/22 | Category 10 | 8.7% | 13.6% |
| 9/1/22 | Category 10 | 9.0% | 14.4% |
| 10/1/22 | Category 10 | 12.6% | 12.6% |
| 11/1/22 | Category 10 | 2.6% | 2.6% |
| 12/1/22 | Category 10 | 0.5% | 0.5% |
| 1/1/23 | Category 10 | 3.9% | 3.9% |
| 2/1/23 | Category 10 | 0.1% | 0.1% |
| 3/1/23 | Category 10 | -8.4% | -8.4% |
| 4/1/23 | Category 10 | -7.7% | -12.1% |
| 5/1/23 | Category 10 | -5.0% | 4.5% |
| 6/1/23 | Category 10 | -6.0% | -6.0% |
| 7/1/23 | Category 10 | -3.0% | -3.0% |
| 8/1/23 | Category 10 | -0.1% | -0.1% |
| 9/1/23 | Category 10 | -1.6% | -6.3% |
| 10/1/23 | Category 10 | -7.2% | -69.1% |
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.