我正在尝试创建一个报告,该报告具有房屋Nbr和街道名称形式的地址。我想按街道名称对所有地址进行分组,然后按房屋nbr对其进行排序,这是一个字符串,但应该像数字一样排序。理想情况下,我希望奇数升序,然后偶数降序,以便我的列表看起来像 1,3,5,7,9 .... 8,6,4,2 我将如何处理?我创建了第一个关于街道名称的组,然后创建了第二个关于门牌号的组,其中包含用于nbrs排序的公式 我用
创建了一个公式字段OddEvenToNumber({tbl_FarmMaster.sano}) MOD 2
但是我很难将其应用于我的小组
答案 0 :(得分:1)
创建如下两个公式。我们称它们为“奇数第一”和“负数甚至”。
oddFirst公式:
{"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"width": 500,
"height": 600,
"autosize": "none",
"signals": [
{
"name": "translate0",
"update": "width / 2"
},
{
"name": "translate1",
"update": "height / 2"
}
],
"projections": [
{
"name": "projection",
"type": "mercator",
"scale": 1000,
"rotate": [
0,
0,
0
],
"center": [
17,
-3
],
"translate": [
{
"signal": "translate0"
},
{
"signal": "translate1"
}
]
}
],
"data": [
{
"name": "drc",
"url": "https://gist.githubusercontent.com/thomas-maschler/ef9891ef03ed4cf3fb23a4378dab485e/raw/47f3632d2135b9a783eeb76d0091762b70677c0d/drc.geojson",
"format": {
"type": "json",
"property": "features"
}
}
],
"marks": [
{
"type": "shape",
"from": {
"data": "drc"
},
"encode": {
"update": {
"strokeWidth": {
"value": 0.5
},
"stroke": {
"value": "darkblue"
},
"fill": {
"value": "lightblue"
},
"fillOpacity": {
"value": 0.5
}
},
"hover": {
"fill": {
"value": "#66C2A5"
},
"strokeWidth": {
"value": 2
},
"stroke": {
"value": "#FC8D62"
}
}
},
"transform": [
{
"type": "geoshape",
"projection": "projection"
}
]
}
]
}
负数甚至公式:
ToNumber({tbl_FarmMaster.sano}) MOD 2 == 1 then
1 //it is odd
else
2 //it is even
然后创建两个要排序的组:
显示{tbl_FarmMaster.sano}字段。