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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Richard_T
New Member

Scatter chart - two data points not in date order

I have an issue with two data points on my XY scatter chart which are not in date order as shown in Fig.1. In this chart, I am trending the output of a manufacturing process ("Crystallinity", Y-axis) against the date the process took place ("Spray Date", X-axis). A legend is added to denote the batch of raw material used. As you can see, I have two data points with a spray date of 10 April 2022 which is displayed between 17 March 2022 and 18 March 2022 but I don't understand why it's out of sequence.

 

I've provided the background of my data and the queries used further below. Can anyone point out if I'm missing something obvious or is this a bug?

 

Fig.1

Pic1.PNG

 

Background information on data and queries

The settings for the X-axis are set to "Don't summarise" and set by "Spray Date" (instead of "Date Hierarchy") as shown in Fig.2.

 

The data source is an Excel sheet on a network drive where the data is entered on the date of spraying (i.e. chronological order). I double checked the Excel sheet and there's nothing different about the date format of these entries compared to the rows above/below it. During the import of data to Power BI, I added a couple of queries to transform the data which includes the assignment of the date format for "Spray Date". All queries pertaining to "Spray Date" are shown in Fig.3.

 

After all queries are complete, I am left with the data shown in Fig.4. The two data points in question are listed in chronological order as per the Excel sheet and nothing looks out of the ordinary for these rows compared to the others. No sorting has been applied to the tabulated data.

 

Fig.2

Pic1.1.png

 

Fig.3

Pic2.png

Pic3.png

 

Fig.4

Pic4.png

 

ETA: Fix grammar

1 ACCEPTED SOLUTION

Hi @Richard_T ,

 

I have tested your data and could replicate the problem and also understand the grouping by date and legend together and then sorting.

 

Since last 2 days, I am trying sorting of x axis date with an index column, but somehow it does not allow date.

 

One more workaround is to use line chart in place of scatter chart, and not use the line color but just the marker color, and sort by date. It works fine even with legend, but you need to specify legend colors manually while publishing the report.

 

mahenkj2_0-1654674509706.png

 

Hope it helps.

View solution in original post

11 REPLIES 11
mahenkj2
Solution Sage
Solution Sage

Hi @Richard_T ,

If possible, can you please share data in table format, just to easily copy and test at our end? Please remove sensitive data, only sample data should be enough.

Hi @mahenkj2, see the post from FarhanAhmed below. It looks like my data has been sub-sorted by date within each category that is listed in my legend. 

https://community.powerbi.com/t5/Desktop/Scatter-chart-two-data-points-not-in-date-order/m-p/2560825...

As requested, here is some sample data between 01 March 2022 and 30 April 2022 so you should be able to recreate the issue I had with the data around 10 April 2022. Let me know how you get on.

 

Spray Date (x-axis)  Powder Batch No (legend)  Crystallinity (y-axis)  
01 March 2022150048458.2
02 March 2022150048459.3
03 March 2022150048461
04 March 2022150048460.5
05 March 2022150048460.2
06 March 2022150048458
07 March 2022150048462.8
08 March 2022150048462.4
09 March 2022150048460
10 March 2022150048462.5
11 March 2022150048465.9
12 March 2022150048462.4
13 March 2022150048467.6
14 March 2022150048465.9
15 March 2022150048461.8
16 March 2022150048458.2
17 March 2022150048454.4
17 March 2022150636954.5
17 March 2022150636959.6
18 March 2022150636959
19 March 2022150636965.4
20 March 2022150636963.36
21 March 2022150636962.62
22 March 2022150636959.79
23 March 2022150636957.2
24 March 2022150636958.89
25 March 2022150636959.86
26 March 2022150636958.68
27 March 2022150636957.2
28 March 2022150636956.3
29 March 2022150636952.19
29 March 2022150636950.44
29 March 2022150636953.62
30 March 2022150636959.97
31 March 2022150636962.67
01 April 2022150636958.54
02 April 2022150636960.71
03 April 2022150636960.73
04 April 2022150636957.15
05 April 2022150636961.28
05 April 2022150636962.15
06 April 2022150636959.19
07 April 2022150636963.87
08 April 2022150636965.37
09 April 2022150636962.89
10 April 2022150636962.45
10 April 2022150636461.95
11 April 2022150636958.55
11 April 2022150636961.78
11 April 2022150636969.94
11 April 2022150636964.53
12 April 2022150636964.61
13 April 2022150636960.96
14 April 2022150636961.93
15 April 2022150636961.43
16 April 2022150636961.82
17 April 2022150636959.21
18 April 2022150636958.02
19 April 2022150636962.94
20 April 2022150636957.67
21 April 2022151428957.89
22 April 2022151428950.62
22 April 2022151428960.45
23 April 2022151428959.66
24 April 2022151428963.6
25 April 2022151428962.59
26 April 2022151428960.36
27 April 2022151428956.49
27 April 2022151428957.37
28 April 2022151428966.5
29 April 2022151428967.71
30 April 2022151428961.3

Hi @Richard_T ,

 

I have tested your data and could replicate the problem and also understand the grouping by date and legend together and then sorting.

 

Since last 2 days, I am trying sorting of x axis date with an index column, but somehow it does not allow date.

 

One more workaround is to use line chart in place of scatter chart, and not use the line color but just the marker color, and sort by date. It works fine even with legend, but you need to specify legend colors manually while publishing the report.

 

mahenkj2_0-1654674509706.png

 

Hope it helps.

Perfect, this is exactly what I was looking for! I didn't think to use a line chart as I thought scatterplot would be the right tool.

I just changed the chart type and I didn't even have to move any of the fields. See below picture, which now shows the two data points correctly at 10 April 2022 instead of sitting within March.

 

Pic7.png

FarhanAhmed
Community Champion
Community Champion

Did you checked your "Sort By" in Visual

 

FarhanAhmed_0-1654506389380.png

 







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




Hi Farhan. Originally, I had not applied any sorting to the chart. I added a sort by "Spray Date" and set to "Sort ascending" but the data is still out of sequence as shown in this new screenshot.

 

Pic5.png

If you see that it is grouping the data based on the legends. then it is applying the sorting.

 

you may want to use another visual if you want your x-axis to be sorted by Date without grouping. You may try out Dual Axis Scatter Chart 







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




I can confirm that removing the legend puts the data back chronological order as shown in the picture below.

 

Whilst this solves the problem, it's not a workable solution for me. I need to easily see when a powder batch change occurs and correlate this with any change in result on Y-axis. Tooltips is too slow to check for every point so the legend/colour coding data points is the most logical solution.

 

Is there really no way to add a legend and not subgroup the data? 

 

Pic6.PNG

Hi @Richard_T 

There is one work around that you can check if possible in your scenario

 

you can assign color to different category using DAX 

 

Color = SWITCH('Table'[Product],
"A","Blue",
"B","Green",
"C","Yellow",
"D","Gray",
"Brown")

 

Then use Marker conditional color expression to Field Value

 

FarhanAhmed_0-1654671783611.png

 

Then you will get results like below sorted by date

 

FarhanAhmed_1-1654671904411.png

 

 

but you will not get the Legends as what color represtenting what data.

may be a table right next to visual something like below to give view like legends. similar conditional formatting apply on the table 

 

FarhanAhmed_2-1654672099699.png

 

see if this works for you.

 

 

 

 

 

 







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




This worked for me. Thanks

Matt

Try using this visual from Store

 

FarhanAhmed_0-1654516210085.png

 







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.