Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Blank deneb visual until slicer selected

Is it possible to set up a Deneb visual to be blank until a slicer is selected?

 

I have a measure that looks like this (is blank until a Country is selected in the slicer):

EventCountrySelected =
VAR CountrySliced2 =
CALCULATE(
    ISFILTERED('EVENTS TEST'[Country]),
    ALLSELECTED('EVENTS TEST'[Country])
)
RETURN
if(
    CountrySliced2,
    sum('EVENTS TEST'[Score_2]),
    BLANK()
)
 
It works just fine in a regular line graph in Power BI. My line graph is blank until I select a country from the slicer.
 
However, I'd like to use a Deneb custom visual I created (also a multi-line graph) as it is more layered/dynamic. It works as it should when I use my "Country" field. So, I tried replacing my "Country" field in deneb with the above measure, and I get a blank graph:
 

 

and when I selected a country in the slicer, it does update, but still doesn't show the country I selected:

 

 

Any tips on how to set the deneb visual to be blank until a country is selected? I double checked my code (see below), the new countryblank measure is all there in vega-lite. I tried using a card that becomes transparent when a slicer is selected but realized that won't work for me because the point of the deneb visual is to be interactive (vertical line on mouseover) and the card prevents me from using mouseover.

 

{
"data": {"name": "dataset"},
"width": 600,
"height": 500,
"layer": [
{
"encoding": {
"x": {"field": "Year_formatted", "type": "temporal", "title": "Years (YYYY)"},
"y": {"field": "Index Score", "type": "quantitative", "title": "Score"},
"color": {"field": "EventCountrySelected", "type": "nominal", "legend": null}
},
"layer": [
{"mark": "line"},
{
"params": [{
"name": "label",
"select": {
"type": "point",
"encodings": ["x"],
"nearest": true,
"on": "mouseover"
}
}],
"mark": "point",
"encoding": {
"opacity": {
"condition": {
"param": "label",
"empty": false,
"value": 1
},
"value": 0
}
}
}
]
},
{
"transform": [{"filter": {"param": "label", "empty": false}}],
"layer": [
{
"mark": {"type": "rule", "color": "gray"},
"encoding": {
"x": {"type": "temporal", "field": "Year_formatted", "aggregate": "min"}
}
},
{
"encoding": {
"text": {"type": "quantitative", "field": "Index Score"},
"x": {"type": "temporal", "field": "Year_formatted"},
"y": {"type": "quantitative", "field": "Index Score"}
},
"layer": [
{
"mark": {
"type": "text",
"stroke": "white",
"strokeWidth": 2,
"align": "left",
"dx": 5,
"dy": -5
}
},
{
"mark": {"type": "text", "align": "left", "dx": 5, "dy": -5},
"encoding": {
"color": {"type": "nominal", "field": "EventCountrySelected"}
}
}
]
}
]
},
{
"mark": {"type": "text", "align": "center", "fontWeight": "bold", "fontSize": 10, "dy": 15},
"encoding": {
"x": {
"field": "Year_formatted",
"type": "temporal"
},
"y": {
"field": "Index Score",
"type": "quantitative"
},
"text": {"field": "Event Name", "type": "nominal"},
"color": {"value": "black"}
}}
]
}

 

Thanks for the wisdom.

2 Replies