Excel - assign the index of every value is a sorted array












0















I know that the question may not really explain what I am asking about, so let me explain it here. Basically, I have a row in my spreadsheet, that contains i.e. 10 values. Let's say it looks like this:



0.60|0.60|0.60|1.40|0.90|1.05|0.00|0.00



Under this row, I have an empty row, and the problem is I have to assign to every of this value it's position in a reversely sorted array of those values (with no duplicates). In this particular case:



Sorted array: 0.00, 0.60, 0.90, 1.05, 1.40



So I would write down a row like this: 4|4|4|1|3|2|5|5| (indexing from 1)



Is there a way to write a formula for this kind of problem? Or do I have to do it manually?










share|improve this question



























    0















    I know that the question may not really explain what I am asking about, so let me explain it here. Basically, I have a row in my spreadsheet, that contains i.e. 10 values. Let's say it looks like this:



    0.60|0.60|0.60|1.40|0.90|1.05|0.00|0.00



    Under this row, I have an empty row, and the problem is I have to assign to every of this value it's position in a reversely sorted array of those values (with no duplicates). In this particular case:



    Sorted array: 0.00, 0.60, 0.90, 1.05, 1.40



    So I would write down a row like this: 4|4|4|1|3|2|5|5| (indexing from 1)



    Is there a way to write a formula for this kind of problem? Or do I have to do it manually?










    share|improve this question

























      0












      0








      0


      1






      I know that the question may not really explain what I am asking about, so let me explain it here. Basically, I have a row in my spreadsheet, that contains i.e. 10 values. Let's say it looks like this:



      0.60|0.60|0.60|1.40|0.90|1.05|0.00|0.00



      Under this row, I have an empty row, and the problem is I have to assign to every of this value it's position in a reversely sorted array of those values (with no duplicates). In this particular case:



      Sorted array: 0.00, 0.60, 0.90, 1.05, 1.40



      So I would write down a row like this: 4|4|4|1|3|2|5|5| (indexing from 1)



      Is there a way to write a formula for this kind of problem? Or do I have to do it manually?










      share|improve this question














      I know that the question may not really explain what I am asking about, so let me explain it here. Basically, I have a row in my spreadsheet, that contains i.e. 10 values. Let's say it looks like this:



      0.60|0.60|0.60|1.40|0.90|1.05|0.00|0.00



      Under this row, I have an empty row, and the problem is I have to assign to every of this value it's position in a reversely sorted array of those values (with no duplicates). In this particular case:



      Sorted array: 0.00, 0.60, 0.90, 1.05, 1.40



      So I would write down a row like this: 4|4|4|1|3|2|5|5| (indexing from 1)



      Is there a way to write a formula for this kind of problem? Or do I have to do it manually?







      excel formula






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 28 '18 at 22:10









      dabljuesdabljues

      1997




      1997
























          1 Answer
          1






          active

          oldest

          votes


















          3














          Use this array formula:



          =MATCH(A1,LARGE(IF(MATCH($A$1:$H$1,$A$1:$H$1,0)=COLUMN($A$1:$H$1)-COLUMN($A$1)+1,$A$1:$H$1),ROW($A$1:INDEX($A:$A,SUMPRODUCT(1/COUNTIF($A$1:$H$1,$A$1:$H$1))))),0)


          Being an array formula one must put the formula in the first cell, confirm with Ctrl-Shift-Enter instead of Enter when exiting edit mode and then copy across.



          The LARGE(IF(MATCH($A$1:$H$1,$A$1:$H$1,0)=COLUMN($A$1:$H$1)-COLUMN($A$1)+1,$A$1:$H$1),ROW($A$1:INDEX($A:$A,SUMPRODUCT(1/COUNTIF($A$1:$H$1,$A$1:$H$1))))) returns the sorted array and the MATCH will find the numbers location in that array.



          Adjust all the ranges to your dataset EXCEPT ...ROW($A$1:INDEX($A:$A,... These are counters and must remain as is regardless where the dataset is located.



          enter image description here






          share|improve this answer





















          • 1





            Absolutely beautiful.

            – BigBen
            Nov 28 '18 at 22:36











          • Jesus, that's terrific. Thank you!

            – dabljues
            Nov 28 '18 at 22:43












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53528878%2fexcel-assign-the-index-of-every-value-is-a-sorted-array%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          Use this array formula:



          =MATCH(A1,LARGE(IF(MATCH($A$1:$H$1,$A$1:$H$1,0)=COLUMN($A$1:$H$1)-COLUMN($A$1)+1,$A$1:$H$1),ROW($A$1:INDEX($A:$A,SUMPRODUCT(1/COUNTIF($A$1:$H$1,$A$1:$H$1))))),0)


          Being an array formula one must put the formula in the first cell, confirm with Ctrl-Shift-Enter instead of Enter when exiting edit mode and then copy across.



          The LARGE(IF(MATCH($A$1:$H$1,$A$1:$H$1,0)=COLUMN($A$1:$H$1)-COLUMN($A$1)+1,$A$1:$H$1),ROW($A$1:INDEX($A:$A,SUMPRODUCT(1/COUNTIF($A$1:$H$1,$A$1:$H$1))))) returns the sorted array and the MATCH will find the numbers location in that array.



          Adjust all the ranges to your dataset EXCEPT ...ROW($A$1:INDEX($A:$A,... These are counters and must remain as is regardless where the dataset is located.



          enter image description here






          share|improve this answer





















          • 1





            Absolutely beautiful.

            – BigBen
            Nov 28 '18 at 22:36











          • Jesus, that's terrific. Thank you!

            – dabljues
            Nov 28 '18 at 22:43
















          3














          Use this array formula:



          =MATCH(A1,LARGE(IF(MATCH($A$1:$H$1,$A$1:$H$1,0)=COLUMN($A$1:$H$1)-COLUMN($A$1)+1,$A$1:$H$1),ROW($A$1:INDEX($A:$A,SUMPRODUCT(1/COUNTIF($A$1:$H$1,$A$1:$H$1))))),0)


          Being an array formula one must put the formula in the first cell, confirm with Ctrl-Shift-Enter instead of Enter when exiting edit mode and then copy across.



          The LARGE(IF(MATCH($A$1:$H$1,$A$1:$H$1,0)=COLUMN($A$1:$H$1)-COLUMN($A$1)+1,$A$1:$H$1),ROW($A$1:INDEX($A:$A,SUMPRODUCT(1/COUNTIF($A$1:$H$1,$A$1:$H$1))))) returns the sorted array and the MATCH will find the numbers location in that array.



          Adjust all the ranges to your dataset EXCEPT ...ROW($A$1:INDEX($A:$A,... These are counters and must remain as is regardless where the dataset is located.



          enter image description here






          share|improve this answer





















          • 1





            Absolutely beautiful.

            – BigBen
            Nov 28 '18 at 22:36











          • Jesus, that's terrific. Thank you!

            – dabljues
            Nov 28 '18 at 22:43














          3












          3








          3







          Use this array formula:



          =MATCH(A1,LARGE(IF(MATCH($A$1:$H$1,$A$1:$H$1,0)=COLUMN($A$1:$H$1)-COLUMN($A$1)+1,$A$1:$H$1),ROW($A$1:INDEX($A:$A,SUMPRODUCT(1/COUNTIF($A$1:$H$1,$A$1:$H$1))))),0)


          Being an array formula one must put the formula in the first cell, confirm with Ctrl-Shift-Enter instead of Enter when exiting edit mode and then copy across.



          The LARGE(IF(MATCH($A$1:$H$1,$A$1:$H$1,0)=COLUMN($A$1:$H$1)-COLUMN($A$1)+1,$A$1:$H$1),ROW($A$1:INDEX($A:$A,SUMPRODUCT(1/COUNTIF($A$1:$H$1,$A$1:$H$1))))) returns the sorted array and the MATCH will find the numbers location in that array.



          Adjust all the ranges to your dataset EXCEPT ...ROW($A$1:INDEX($A:$A,... These are counters and must remain as is regardless where the dataset is located.



          enter image description here






          share|improve this answer















          Use this array formula:



          =MATCH(A1,LARGE(IF(MATCH($A$1:$H$1,$A$1:$H$1,0)=COLUMN($A$1:$H$1)-COLUMN($A$1)+1,$A$1:$H$1),ROW($A$1:INDEX($A:$A,SUMPRODUCT(1/COUNTIF($A$1:$H$1,$A$1:$H$1))))),0)


          Being an array formula one must put the formula in the first cell, confirm with Ctrl-Shift-Enter instead of Enter when exiting edit mode and then copy across.



          The LARGE(IF(MATCH($A$1:$H$1,$A$1:$H$1,0)=COLUMN($A$1:$H$1)-COLUMN($A$1)+1,$A$1:$H$1),ROW($A$1:INDEX($A:$A,SUMPRODUCT(1/COUNTIF($A$1:$H$1,$A$1:$H$1))))) returns the sorted array and the MATCH will find the numbers location in that array.



          Adjust all the ranges to your dataset EXCEPT ...ROW($A$1:INDEX($A:$A,... These are counters and must remain as is regardless where the dataset is located.



          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 28 '18 at 22:40

























          answered Nov 28 '18 at 22:34









          Scott CranerScott Craner

          93.3k82652




          93.3k82652








          • 1





            Absolutely beautiful.

            – BigBen
            Nov 28 '18 at 22:36











          • Jesus, that's terrific. Thank you!

            – dabljues
            Nov 28 '18 at 22:43














          • 1





            Absolutely beautiful.

            – BigBen
            Nov 28 '18 at 22:36











          • Jesus, that's terrific. Thank you!

            – dabljues
            Nov 28 '18 at 22:43








          1




          1





          Absolutely beautiful.

          – BigBen
          Nov 28 '18 at 22:36





          Absolutely beautiful.

          – BigBen
          Nov 28 '18 at 22:36













          Jesus, that's terrific. Thank you!

          – dabljues
          Nov 28 '18 at 22:43





          Jesus, that's terrific. Thank you!

          – dabljues
          Nov 28 '18 at 22:43




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53528878%2fexcel-assign-the-index-of-every-value-is-a-sorted-array%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)