英文:
How can I sum the values on Power BI Deneb?
问题
我有一个表格,其中包含我想在Power BI Deneb柱状图上显示的数值。
| 损失原因 | 主要数量损失 |
|---|---|
| Chupados | 1 |
| 通用终止 | 18530 |
| 通用终止 | 929 |
| 通用终止 | 980 |
| Leitosas | 1 |
| Manchas | 1 |
但是这些值没有聚合值叠加在一起,显示的值应该是20.439,而不是分别显示在同一根柱上的18530/929/980。
我使用了以下规范:
{
"data": {"name": "dataset"},
"layer":[{
"mark": "bar"},
{
"mark": {"type": "text", "color": "black", "xOffset": 8},
"encoding": {
"text": {"field": "PrimaryQuantityLoss", "type": "quantitative"}}
}]
,
"encoding": {
"x": {
"field": "PrimaryQuantityLoss",
"type": "quantitative"
},
"y": {
"field": "LossReason",
"type": "ordinal"
}
}
}
我尝试进行总和聚合,但没有成功。
英文:
I have a table with the values that I want to display on Power BI Deneb Bar chart.
| LossReason | PrimaryQuantityLoss |
|---|---|
| Chupados | 1 |
| Generic Terminate | 18530 |
| Generic Terminate | 929 |
| Generic Terminate | 980 |
| Leitosas | 1 |
| Manchas | 1 |
But the values are not aggregating Values stacked one above the others , the value displayed should be 20.439 instead of 18530/929/980 separated on the same bar.
I'm using the following specification:
{
"data": {"name": "dataset"},
"layer":[{
"mark": "bar"},
{
"mark": {"type": "text", "color": "black", "xOffset": 8},
"encoding": {
"text": {"field": "PrimaryQuantityLoss", "type": "quantitative"}}
}]
,
"encoding": {
"x": {
"field": "PrimaryQuantityLoss",
"type": "quantitative"
},
"y": {
"field": "LossReason",
"type": "ordinal"
}
}
}
I tried to do an aggregate by sum, but doesn't worked.
答案1
得分: 0
将"PrimaryQuantityLoss"更改为"PrimaryQuantityLoss的总和"。如下,我们可以手动完成。
(1) 转到可视化 > 值 > "PrimaryQuantityLoss" 并选择 总和。
(2) 然后会出现一个消息窗口来设置字段。选择 Sum of PrimaryQuantityLoss 作为新分配的字段。
(3) 完成。您会注意到文本编码和x字段都已更新。
新规格如下:
{
"data": {"name": "dataset"},
"layer":[{
"mark": "bar"},
{
"mark": {"type": "text", "color": "black", "xOffset": 8},
"encoding": {
"text": {"field": "Sum of PrimaryQuantityLoss", "type": "quantitative"}}
}]
,
"encoding": {
"x": {
"field": "Sum of PrimaryQuantityLoss",
"type": "quantitative"
},
"y": {
"field": "LossReason",
"type": "ordinal"
}
}
}
英文:
Change "PrimaryQuantityLoss" to "Sum of PrimaryQuantityLoss". As below, we can do it manually.
(1) Go to Visualizations > Values > "PrimaryQuantityLoss" and select Sum.
(2) Then a message window will appear to set the Field. Select Sum of PrimaryQuantityLoss as newly assigned field.
(3) Done. You will notice that the text encoding and the x-field are both renewed.
New specification is:
{
"data": {"name": "dataset"},
"layer":[{
"mark": "bar"},
{
"mark": {"type": "text", "color": "black", "xOffset": 8},
"encoding": {
"text": {"field": "Sum of PrimaryQuantityLoss", "type": "quantitative"}}
}]
,
"encoding": {
"x": {
"field": "Sum of PrimaryQuantityLoss",
"type": "quantitative"
},
"y": {
"field": "LossReason",
"type": "ordinal"
}
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。





评论