Forum Discussion
Deneb Sorting Issue when "Datum" is included
- 1 year ago
If you want to use one instance of the value and it's repeated for each row, can you use average or min as an aggregate instead of sum?
Hi dm-p ,
The way sorting works now is correct, however if you see the Target bar, in the PBIX or the screen shot you attached, it is way higher than the overall sum of profit in Target Table (15 ), and its changing when i change dates in my slicer and reaching around 135 too. It is supposed to be 15 and not more that.
Please let me know, If you need any other details.
Thanks,
Vamshi.
Thanks.
If you want to use one instance of the value and it's repeated for each row, can you use average or min as an aggregate instead of sum?
- vamshi_pbims1 year ago
Microsoft Employee
Hi dm-p ,
Thank you very much for the help,
I had to modify the code like below from your code, to get the output for my requirement. And I have commeneted the aggregated part inorder to make my legend working, else its showing as "Undefined" for "Target" bar. And I had to remove "SortOrd" field from visual otherwise the datum bar is coming at starting in the chart instead of end. The trick for my requirement was to use sort: {"op":"min"} in the encoding.
{ "data": { "name": "dataset" } , "transform": [ { "filter": "datum['Sum Of Price'] != null " } ] , "layer": [ { "mark": { "type": "bar", "tooltip": true }} , { "mark": { "type": "bar", "tooltip": true }, "encoding": { "x":{"datum":"Target","type": "nominal"}, "y": { "aggregate":"min", "field": "Target_m", "type": "quantitative" } } } ] , "encoding": { "x": { "field": "MonthYear", "sort":{"field":"SortOrd","op": "min" }, "type": "nominal" }, "y": { "field": "Sum Of Price", "type": "quantitative" },"color": {"field":"Product"} } }Thanks Again,
Vamshi.