Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
JayeeDee
Frequent Visitor

How to unalign points?

Can someone help me figure out how to make it so the points for 'City 3' are not aligned on the same x-axis? Each occurs in its own row and has a Year or YearId column that I'd like to use to solve it, but I'm not sure how. I did some research and found detail channel, but that did not work.

 

chart-ref-1.png

 

 
 
 
 
 
 
 
 
 
 
 
```DemoTable = DATATABLE(
"Year", INTEGER,
"CurrentPlayer", STRING,
"Date", DATETIME,
"YearId", STRING,
"City", STRING,
"Winner", STRING,
"Round", INTEGER,
  {
    {2019,"Bill","04/02/2019","2019-76","City 1","Sue", 4},
    {2019,"Bill","05/02/2019","2019-146","City 2","Sally", 2},
    {2020,"Bill","09/07/2020","2020-205","City 3","Randy", 7},
    {2021,"Bill","05/03/2021","2021-205","City 3","Randy", 3},
    {2022,"Bill","05/02/2022","2022-205","City 3","Andre", 6},
    {2023,"Bill","05/08/2023","2023-205","City 3","Dan", 4},
    {2024,"Bill","05/06/2024","2024-205","City 3","Barry", 5},
    {2025,"Bill","05/05/2025","2025-205","City 3","Barry", 3}
  }
)```
 
```
{
  "title": "Annual Performance",
  "description": "Annual performance of ATP player",
  "width": 570,
  "data": {"name": "dataset"},
  "layer": [
    {
      "mark": {
        "type": "line",
        "tooltip": true
      },
      "encoding": {
        "y": {
          "field": "Level",
          "type": "quantitative",
          "axis": {"title": "Level"}
        },
        "x": {
          "field": "City",
          "type": "nominal",
          "sort": {"field": "Date", "order": "ascending"},
          "axis": {
            "title": "City",
            "labelAngle":-50
          }
        }
      }
    },
    {
      "mark": {
          "type": "point",
          "tooltip": true,
          "filled": true
      },
      "encoding": {
        "y": {
          "field": "Level",
          "type": "quantitative",
          "axis": {"title": "Level"}
          },
        "x": {
          "field": "City",
          "type": "ordinal",
          "sort": {"field": "Date", "order": "ascending"}
        },
        "color": {
          "condition": {
              "test": "datum.Round === 7 && datum.Winner === datum.CurrentPlayer",
              "value": "red"
          },
        "value": "DodgerBlue"
        }
      }
    }
  ]
}
```
1 ACCEPTED SOLUTION

Make the year the x axis and the city the legend.

 

Note: since year is temporal you could now even reconsider using a line chart, a stacked line chart, or a ribbon chart.

View solution in original post

9 REPLIES 9
lbendlin
Super User
Super User

Do not use a line chart for independent (nominal) data points. Line charts should only ever be used to show temporal progression, or phase transitions.

What would you recommend for my use case?

I would recommend a column chart.

Which one is column? Or are you referring to power bi types?

JayeeDee_1-1766418484668.png

 

"mark": {
    "type": "bar"
  },
"encoding": {
        "y": {
          "field""Level",
          "type""quantitative"
          },
        "x": {
          "field""City",
          "type""nominal"
        }
      }

The bar for City 3 still stacks them altogether. Can you suggest how to solve it with a mark of type bar?

JayeeDee_0-1766422328291.png

 

Make the year the x axis and the city the legend.

 

Note: since year is temporal you could now even reconsider using a line chart, a stacked line chart, or a ribbon chart.

GeraldGEmerick
Memorable Member
Memorable Member

@JayeeDee What would you like it to look like instead? You could add additional columns to the x-axis to make a hierarchy that you could drill through but I am unclear if that that is what you are looking to do. Maybe a sketch of what you would rather have?

Absolutely! Here's the desired outcome...

chart.jpeg

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.