Forum Discussion
Help to add Custom Visual in PowerBI Desktop
- 10 years ago
Right now your [Device Status] column is being sorted alphabetically which is why Offline is on the bottom and Online is on top of the stacked column chart. To reverse the order of these you need to add another column to the table that has [Device Status] that can be used to change the sort order of [Device Status]. Add a column in the edit queries step that is 1 whenever [Device Status] = "Online" and 2 the rest of the time. In the Home ribbon go to Edit Queries -> Add Column - > Add Custom Column. The Add Column Step would look like this:
= if [Status] = "Online" then 1 else 2
Then Close & Apply the changes. Now go to the data view -> select the status column -> Modeling ribbon -> Sorty By Column -> chose to sort by the new column that was added.
Now the visual should have Online on the bottom of the chart and Offline on top.
-Anthony
You almost have it working! You don't need the [Sort Device] column in any of the chart fields. Just make sure in the data model you have set the [Device Status] column to be sorted by the [Sort Device] column. Then put the [Device Status] column as the chart Legend like you did in the original chart.
Here is a tutorial on how that explains the steps you need to do to sort the [Device Status] column by the [Sort Device] column.
It works! Thanks Twan!
My next challange is this, my data so far consisting of row from date 29th Feb until 2nd March. When I view the report on daily level, it is divided by date, 29 Feb on the right, 1-2 March on the left (refer to DULT report). Can we view it historically from left to right so the end user didn't get confused?