Excel formula comparison

RD1982

New Member
Joined
Nov 10, 2022
Messages
39
Office Version
  1. 365
Platform
  1. Windows
Hi Excel Gurus - Could you pls help me to find a formula that will give me the comparison between below table - from previous to current week - of main 3 lanes impacted (increase/decrease %)?

For instance, from TAS > VIC on WC26 was performance 80% but next week (WC 04) dropped to 60%, the formula would let me know the combination of "from/to" from one week to another which "from/to" had the highest impact by increasing/decreasing %.

WC 26​
WC 04
FromTo%FromTo%
QLDSA100%QLDSA90%
QLDTAS100%SydneyVIC70%
TASVIC80%TASVIC60%
SydneyVIC60%SydneyPerth50%
SydneyPerth50%QLDTAS20%
1709600991223.png
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Do you mean something like this?

Book2
ABCDEFGHIJ
1WC 26WC 04Comparison
2FromTo%FromTo%FromToChange
3QLDSA100%QLDSA90%QLDTAS-80%
4QLDTAS100%SydneyVIC70%TASVIC-20%
5TASVIC80%TASVIC60%QLDSA-10%
6SydneyVIC60%SydneyPerth50%SydneyVIC10%
7SydneyPerth50%QLDTAS20%SydneyPerth0%
Sheet7
Cell Formulas
RangeFormula
H3:J7H3=LET(a,A3:A7,b,B3:B7,t,CHOOSE({1,2,3},a,b,SUMIFS(F3:F7,D3:D7,a,E3:E7,b)-C3:C7),SORTBY(t,ABS(INDEX(t,0,3)),-1))
Dynamic array formulas.
 
Upvote 0
Hi @Eric W - Amazing your formula!!! I never used LET at all even less with the combination you have done genius. I cannot replicate into my file I may be missing something see below. Help?

As I use 2 different reports after SUMIF I need to capture from last week as shown below...I didn't get the concept of "t 1, 2, 3" neither the end as "t" index (t,0,3) is the 3 the related to column C %?

1709705044787.png
 
Upvote 0
Let's see if I can clear things up a bit. LET is a relatively new function. It basically allows you to define some intermediate variables, then string several functions together, without having to redefine each variable every time you want to use it. I used some basic variable names, but they weren't clear as to what they are. So some of them you probably didn't know whether to add a sheet reference or not. So I rewrote it with some more understandable names (I hope!) and put them all up front, so you don't have to go too deep to modify it. If your last week sheet looks like:

Book2
ABCDEFGHI
1FromTo%
2QLDSA100%
3QLDTAS100%
4TASVIC80%
5SydneyVIC60%
6SydneyPerth50%
Last Week


Then the "This Week" sheet should look like:

Book2
ABCDEFGHIJKLMN
1FromTo%
2QLDSA90%QLDTAS-80%
3SydneyVIC70%TASVIC-20%
4TASVIC60%QLDSA-10%
5SydneyPerth50%SydneyVIC10%
6QLDTAS20%SydneyPerth0%
This Week
Cell Formulas
RangeFormula
L2:N6L2=LET(TWSupp,B2:B6,TWRec,C2:C6,TWPct,I2:I6,LWSupp,'Last Week'!B2:B6,LWRec,'Last Week'!C2:C6,LWPct,'Last Week'!I2:I6,dif,SUMIFS(TWPct,TWSupp,LWSupp,TWRec,LWRec)-LWPct,table,CHOOSE({1,2,3},LWSupp,LWRec,dif),SORTBY(table,ABS(INDEX(table,0,3)),-1))
Dynamic array formulas.


The formula is (I added a few line feeds for clarity):

Excel Formula:
=LET(TWSupp,B2:B6,
          TWRec,C2:C6,
          TWPct,I2:I6,
          LWSupp,'Last Week'!B2:B6,
          LWRec,'Last Week'!C2:C6,
          LWPct,'Last Week'!I2:I6,
          dif,SUMIFS(TWPct,TWSupp,LWSupp,TWRec,LWRec)-LWPct,
          table,CHOOSE({1,2,3},LWSupp,LWRec,dif),
          SORTBY(table,ABS(INDEX(table,0,3)),-1))

Let me break it down a bit for you. The first variable is TWSupp (This Week Supplier), then TWRec (This Week Receiver), then TWPct (This Week Percent), then LWSupp, LWRec, and LWPct. So you should see pretty easy which ones need the sheet references.

The next variable is dif (difference). This is an intermediate result. The SUMIFS uses the already defined variables (ranges) to find the "This Week" percentages in the same order they are listed in the "Last Week" sheet. Then we subtract the LWPct to get the difference (change).

The next variable is table, another intermediate result. The CHOOSE function is used here to create a table with 3 columns, LWSupp, LWRec, and dif.

And finally we have the SORTBY. This sorts the table we just made by the absolute value of the third column. INDEX(table,0,3) - The 0 means we want all the rows, the 3 means the 3rd column like you surmised.

Hopefully this clears things up a bit! If not, let me know.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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