Is it possible to code Vega in such a way as to perform certain operations if filter is not applied
?
objective: if the filter is applied, then perform code given below, if filter is not applied then perform sum of a different field value
Here is my Vega code for reference :
{
$schema: https://vega.github.io/schema/vega/v3.0.json
data: [
{
name: latestTotalBalance
url: {
%context%: true
%timefield%: @timestamp
index: wallet-info*
body: {
aggs: {
label: {
terms: {
field: info.displayName.keyword
size: 30
order: {_key: "desc"}
}
aggs: {
balance: {
top_hits: {
_source: confirmedBalanceUnitAmount
size: 2
sort: [
{
@timestamp: {order: "desc"}
}
]
}
}
}
}
}
size: 0
}
}
format: {property: "aggregations.label.buckets"}
transform: [
{
type: aggregate
ops: ["sum"]
fields: ["balance.hits.hits[0]._source.confirmedBalanceUnitAmount"]
as: ["totalUnitAmount"]
}
]
}
]
marks: [
{
type: text
from: {data: "latestTotalBalance"}
encode: {
update: {
text: {signal: "format(datum.totalUnitAmount, ',')"}
align: {value: "center"}
baseline: {value: "middle"}
xc: {signal: "width/2"}
yc: {signal: "height/2"}
fontSize: {signal: "33"}
"fill": {"value": "white"}
"fontWeight":{"value": "bold"}
text: {signal: "format(datum.totalUnitAmount, ',.5f')"}
}
}
}
]
}