Power BI: How to create a scatter plot with X-axis dates?

6.4k views Asked by At

I'm trying to create a simple scatter plot, with dates on the X axis and a count of events on the Y axis. In Excel it's easy: Excel recognizes the dates as legitimate axis material and automatically figures out logical increments.

Excel example

But Power BI can't seem to manage that. When I assign the same two columns as I did in Excel, I get a nastygram:

BI error

My date table has a numeric "DayCounter" field, which is a numeric count of days since 1900 or thereabouts. Power BI likes that as an axis, but the increments will mean nothing to a human.

BI chart

How do I get the BI axis to show dates?

2

There are 2 answers

1
Ozan Sen On

Step_1: For [DateCounter] numeric column field, go to the query editor as you can see in the picture below:

Query Editor Section

Step_2: Click the top left corner, and change the data type from whole number to Date.

Change the data type

Step_3: You can see the converted data to date.

dfsadgffg

Step_4: Then exit the query editor, and go on to create the scatter chart. Put the [DateCounter] in the X_axis, and count on the y axis. Done! I tested a similar scenario with a fake data using scatter chart and a slicer to constrain the date column.

Test With Data

0
reo katoa On

It's a bit insane, but this seems to be the way to do what you want: use a line chart to create a scatter plot. By default it looks like this:

enter image description here

Unlike the scatter plot, this chart has a notion of continuous vs. categorical values:

enter image description here

The scatter plot would show your data as evenly-spaced data points, sorted by date but with none of the information about the distance between dates. The line chart knows that dates mean something.

Now all that's left is to make it look the way you want. To do this, set the stroke width to 0 px and turn markers on:

enter image description here

Et voila:

enter image description here