Is there a way to sort a table without screwing up a scatter chart based on that table?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,533
Office Version
  1. 365
Platform
  1. Windows
Please bear with my rather long and involved intro. The question is at the end.

In my effort to convert Amazon-type ratings to meaningful z scores, I came up with the table below. Columns F-J are used to calculate columns L-P, which are used to calculate the mean and std dev, which are used to calculate the confidence intervals, which are used to adjust the ratings, which can then be converted to z scores.

Amazon Ratings.xlsx
BCDEFGHIJKLMNOPQRSTUVWXYZ
2Alpha0.050.59490355Coefficient
3-0.5Exponent
4SKURtg#ReviewsRank15%4%3%2%1%%Sum#5#4#3#2#1MeanStd DevConf IntRtg AdjRank2RtgΔRankΔConf Int2CIΔ%RtgZ
53930810874.99,651791%6%2%0%1%100%8,7825791930974.86000.52950.00614.89440.006+30.00610.0000%+0.56
6B0BS8G1ZB64.93,259893%5%1%0%1%100%3,031163330334.89000.48770.01044.89050.010+30.01040.0000%+0.53
7B08QTLYPVT4.91,518990%8%1%0%1%100%1,366121150154.86000.51030.01534.88560.015+30.01530.0000%+0.49
8B0C2H44ZDY4.96041091%7%2%1%0%101%5504212604.91000.47220.02424.87670.024+30.02420.0000%+0.42
9B0BTSFVMLV4.92861197%1%0%1%1%100%27730334.92000.50360.03524.86580.035+30.03520.0000%+0.34
10B0C2BMNHW25.0221195%5%0%0%0%100%210110004.95000.21790.04004.96010.040=00.04000.0000%+1.04
11B0BWH7788Y5.0193297%1%2%0%0%100%18724004.95000.29580.04284.95720.043=00.04280.0000%+1.02
12B00KJ0CDUQ4.91511291%6%2%0%1%100%13793024.86000.52950.04844.85290.048+30.04840.0000%+0.25
13B0BKRSD6HN4.9881386%14%0%0%0%100%76120004.86000.34700.06344.837100.063+30.06340.0000%+0.14
14B0C1NWLRHM5.0853100%0%0%0%0%100%8500005.00000.00000.06454.93530.065=00.06450.0000%+0.86
15B07WX53GCK4.9161488%12%0%0%0%100%1420004.88000.32500.14874.751120.149+20.14870.0000%-0.49
16B09C8YYY2T4.9151589%11%0%0%0%100%1320004.89000.31290.15364.746130.154+20.15360.0000%-0.53
17B0BN4GPZ144.9111688%12%0%0%0%100%1010004.88000.32500.17944.721140.179+20.17940.0000%-0.71
18B0BJ14XC5Q5.0104100%0%0%0%0%100%1000005.00000.00000.18814.812110.188-70.18810.0000%-0.04
19B0BJNZ8TGX5.045100%0%0%0%0%100%400005.00000.00000.29754.703150.297-100.29750.0000%-0.85
20B0BRMLQBG75.016100%0%0%0%0%100%100005.00000.00000.59494.405160.595-100.59490.0000%-3.03
21Averages4.91,00794%6%1%0%0%9225916194.91940.30350.11954.8180.1195-0.00
22Standard Deviations0.136+1.00
Chart & Sort
Cell Formulas
RangeFormula
L5:L20L5=[@['#Reviews]]*[@[5%]]
M5:M20M5=[@['#Reviews]]*[@[4%]]
N5:N20N5=[@['#Reviews]]*[@[3%]]
O5:O20O5=[@['#Reviews]]*[@[2%]]
P5:P20P5=[@['#Reviews]]*[@[1%]]
Q5:Q20Q5=SUM([@['#5]]:[@['#1]]*{5,4,3,2,1})/[@['#Reviews]]
R5:R20R5=SQRT(SUM(({5,4,3,2,1}-[@Mean])^2*[@['#5]]:[@['#1]])/[@['#Reviews]])
S5:S20S5=CONFIDENCE.NORM(Alpha,TblAmz3[[#Totals],[Std Dev]],[@['#Reviews]])
L21L21=SUBTOTAL(101,['#5])
M21M21=SUBTOTAL(101,['#4])
N21N21=SUBTOTAL(101,['#3])
O21O21=SUBTOTAL(101,['#2])
P21P21=SUBTOTAL(101,['#1])
Q21Q21=SUBTOTAL(101,[Mean])
R21R21=SUBTOTAL(101,[Std Dev])
S21S21=SUBTOTAL(101,[Conf Int])
U5:U20U5=RANK.EQ([@[Rtg Adj]],[Rtg Adj])
V5:V20V5=[@Rtg]-[@[Rtg Adj]]
W5:W20W5=[@Rank1]-[@Rank2]
E5:E20E5=RANK([@Rtg],[Rtg])+SUMPRODUCT(--([Rtg]=[@Rtg]),--([@['#Reviews]]<['#Reviews]))
K5:K20K5=SUM([@[5%]]:[@[1%]])
Y5:Y20Y5=([@[Conf Int2]]/[@[Conf Int]])-1
C21C21=SUBTOTAL(101,[Rtg])
D21D21=SUBTOTAL(101,['#Reviews])
F21F21=SUBTOTAL(101,[5%])
G21G21=SUBTOTAL(101,[4%])
H21H21=SUBTOTAL(101,[3%])
I21I21=SUBTOTAL(101,[2%])
J21J21=SUBTOTAL(101,[1%])
X5:X20X5=Coef * ([@['#Reviews]]^Expon)
X21X21=SUBTOTAL(101,[Conf Int2])
T5:T20T5=[@Rtg]-[@[Conf Int]]
T21T21=SUBTOTAL(101,[Rtg Adj])
T22T22=STDEV.S(TblAmz3[Rtg Adj])
Z5:Z20Z5=([@[Rtg Adj]]-TblAmz3[[#Totals],[Rtg Adj]])/RtgAdjStdDev
Z21Z21=SUBTOTAL(101,[RtgZ])
Z22Z22=STDEV.S(TblAmz3[RtgZ])
Named Ranges
NameRefers ToCells
'Chart & Sort'!Alpha='Chart & Sort'!$S$2S5:S20
'Chart & Sort'!Coef='Chart & Sort'!$X$2X5:X20
'Chart & Sort'!Expon='Chart & Sort'!$X$3X5:X20
'Chart & Sort'!RtgAdjStdDev='Chart & Sort'!$T$22Z5:Z20


To see whether there is a reliable relationship between the number of reviews and the confidence intervals, I plotted them in a scatter chart and added a trendline. It turns out that a power equation is a near perfect fit. I don't see a way to post a chart using xl2bb, so here it is as a graphic.

image.png
I then use that

I then used that equation to compute a confidence interval directly from the number of reviews. There is very little difference. This allows me to bypass all of the other math above and calculate adjusted ratings directly from the number of reviews.

Here's the problem. I would like to be able to sort the table in several ways, but if I do, the chart gets all screwed up. Here's what happens if I sort the table on the Rank1 field.

image.png


Or if I sort it on the SKU column.

image.png



Is there any way that I can set it up so that I can sort the table anyway I want without affecting the chart?

I do not want to freeze the chart, unless there is also a way to unfreeze it, as I may want to add additional rows to the table and have te chart and trendline updated.

Thanks. I hope this was not too muddled.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
A scatter chart shouldn't be affected by sorting unless the values being plotted are changed by sorting (the order shouldn't affect where they plot, after all).
 
Upvote 0
If Rory's suggestion doesn't pan out for you, how about building the chart on a dynamically sorted table.

eg if the main table you are showing is is named Table1 and the order in your chart is column 3 in descending order then have a table using the formulas below as the basis for your chart.

Note: to create the chart I just made my active cell the cell containg the "sort" function, excel seemed to figure out the rest.

Book1
BCDEF
25ProductAmtCol3Col4Index
26Banana100600005
27Apple30500002
28Kiwi10200001
29Pear500100003
30Orange4050004
31carrot100010006
Sheet1
Cell Formulas
RangeFormula
B25:F25B25=Table1[#Headers]
B26:F31B26=SORT(Table1,3,-1)
Dynamic array formulas.
 
Upvote 0
Hmmm for some reason that I don't understand just using sort is not automatically increasing the size of the range in the chart.
It only increased dynamically if added a filter into the mix (used a filter that would select everything)

Book1
BCDEF
31ProductAmtCol3Col4Index
32Banana100600005
33Apple30500002
34Kiwi10200001
35Pear500100003
36Add an Item1000100000
37Item 780090000
38Orange4050004
Sheet1
Cell Formulas
RangeFormula
B31:F31B31=Table1[#Headers]
B32:F38B32=SORT(FILTER(Table1,Table1[Product]<>"",""),3,-1)
Dynamic array formulas.
 
Upvote 0
A scatter chart shouldn't be affected by sorting unless the values being plotted are changed by sorting (the order shouldn't affect where they plot, after all).
That's what I thought, but unless I am doing something wrong, it doesn't work that way. Here's a simpler example.

I started with this table that is sorted on the #Reviews column:

Amazon Ratings.xlsx
CDEF
5Rtg#ReviewsRankConf
659,46710.0132
739,10120.0130
848,49930.0136
9574440.0445
10444450.0608
11342760.0625
1258870.1328
1345680.1673
1433990.2045
1549100.4081
1654110.6270
1732120.8727
MrExcel
Cell Formulas
RangeFormula
E6:E17E6=RANK.EQ([@['#Reviews]],['#Reviews])


I made this plot with the #Reviews column on the X axis and the Conf column on the Y axis.

1683667054708.png


1683667892236.png


If I sort the table on Rtg / #Reviews:

Amazon Ratings.xlsx
CDEF
5Rtg#ReviewsRankConf
659,46710.0132
7574440.0445
858870.1328
954110.6270
1048,49930.0136
11444450.0608
1245680.1673
1349100.4081
1439,10120.0130
15342760.0625
1633990.2045
1732120.8727
MrExcel
Cell Formulas
RangeFormula
E6:E17E6=RANK.EQ([@['#Reviews]],['#Reviews])


I get this chart:

1683667299189.png


If I resort it on the #Reviews column, the chart is also restored.

???????????????
 
Upvote 0
That was me being daft and not looking at what your lines were. If you join the points, then it will matter what order they are in.
 
Upvote 0
I mean you are using lines not just plotting the individual data points.
 
Upvote 0
Solution
I mean you are using lines not just plotting the individual data points.
I'm pretty sure that I am the one being daft. 🤨😣

You are exactly right. The chart did not change. It was just the lines between the points that changed. If I do a plot with just dots, it works.

1683741695475.png


I can sort the table any which way and the chart remains the same.

Thank you

PS: I'll have to think about whether I think this is a design bug...
 
Upvote 0

Forum statistics

Threads
1,215,103
Messages
6,123,106
Members
449,096
Latest member
provoking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top