Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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

 

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

 

Fig.3

 

Fig.4

 

ETA: Fix grammar

  • mahenkj2's avatar
    mahenkj2
    4 years ago

    Hi Anonymous ,

     

    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.

     

     

    Hope it helps.

11 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      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.

       

      • FarhanAhmed's avatar
        FarhanAhmed
        Community Champion

        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 

  • mahenkj2's avatar
    mahenkj2
    Solution Sage

    Hi Anonymous ,

    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.

    • Anonymous's avatar
      Anonymous
      Not applicable

      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/highlight/true#M905750

      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
      • mahenkj2's avatar
        mahenkj2
        Solution Sage

        Hi Anonymous ,

         

        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.

         

         

        Hope it helps.