Excel SORTBY Function: Complete Guide with Examples

SORTBY Function


Microsoft Excel में बड़े डेटा को व्यवस्थित करना किसी भी रिपोर्ट, dashboard या analysis का महत्वपूर्ण हिस्सा है। सामान्यतः Excel में डेटा को Sort करने के लिए Sort & Filter का उपयोग किया जाता है। लेकिन जब आपको किसी दूसरे column, अलग range या calculated result के आधार पर डेटा को automatically sort करना हो, तब SORTBY function बहुत उपयोगी साबित होता है।

SORTBY एक modern Excel Dynamic Array Function है, जिसकी मदद से आप किसी range या array को एक या एक से अधिक criteria के आधार पर ascending या descending order में sort कर सकते हैं। इसका सबसे बड़ा फायदा यह है कि आपको source data को manually sort करने या helper column बनाने की आवश्यकता नहीं होती।

यह function विशेष रूप से Excel 365 और Excel 2021 तथा बाद के compatible Excel versions में dynamic-array functionality के साथ उपयोगी है।



1. SORTBY Function क्या है?

Excel का SORTBY function किसी array या range को एक या अधिक दूसरी arrays के values के आधार पर sort करता है।

सरल शब्दों में:

SORTBY का उपयोग किसी data range को किसी दूसरे column या range की values के आधार पर sort करने के लिए किया जाता है।

मान लीजिए आपके पास यह data है:

Employee Sales
Amit 50000
Ravi 75000
Neha 45000
Priya 90000

अगर आपको employees को Sales के आधार पर highest से lowest क्रम में दिखाना है, तो SORTBY आपकी मदद कर सकता है।

Formula:

=SORTBY(A2:A5,B2:B5,-1)

Result:

Employee

Priya

Ravi

Amit

Neha

यहाँ Employee column को Sales column के आधार पर sort किया गया है।



2. SORTBY Function का Syntax

SORTBY का basic syntax है:

=SORTBY(array,by_array1,[sort_order1],[by_array2,sort_order2],...)

इसके मुख्य arguments को समझते हैं।

array

यह वह range या array है जिसे आप sort करना चाहते हैं।

उदाहरण:

A2:C10

by_array1

यह वह range है जिसके values के आधार पर array को sort किया जाएगा।

उदाहरण:

B2:B10

sort_order1

यह निर्धारित करता है कि sorting किस direction में होगी।

  • 1 = Ascending
  • -1 = Descending

अगर इसे नहीं लिखा जाए तो सामान्यतः ascending order लिया जाता है।

by_array2

यह दूसरा sorting criterion है।

sort_order2

यह दूसरे criterion का sorting order है।

इस तरह आप कई criteria के आधार पर sorting कर सकते हैं।



3. SORTBY का सबसे आसान Example

मान लीजिए:

Product Sales
Laptop 50000
Mobile 30000
Monitor 20000
Printer 15000

आप Product को Sales के आधार पर ascending order में sort करना चाहते हैं।

Formula:

=SORTBY(A2:A5,B2:B5,1)

Result:

Product

Printer

Monitor

Mobile

Laptop

क्योंकि Sales का क्रम है:

15,000 → 20,000 → 30,000 → 50,000



4. Descending Order में SORTBY

अब अगर हमें highest sales से lowest sales दिखानी है:

=SORTBY(A2:A5,B2:B5,-1)

Result:

Product

Laptop

Mobile

Monitor

Printer

यह technique sales reports और performance dashboards में बहुत उपयोगी है।



5. Example 1: Employee Salary के आधार पर Sorting

मान लीजिए HR department के पास यह data है:

Employee Department Salary
Amit IT 65000
Neha HR 55000
Ravi IT 85000
Priya Finance 75000
Karan HR 50000

अगर हमें पूरी table को Salary के आधार पर highest से lowest sort करना है:

=SORTBY(A2:C6,C2:C6,-1)

Result:

Employee Department Salary
Ravi IT 85000
Priya Finance 75000
Amit IT 65000
Neha HR 55000
Karan HR 50000

ध्यान दें कि हमने केवल Employee column नहीं बल्कि A2:C6 पूरी range को sort किया है। इससे employee के साथ Department और Salary भी सही row में रहते हैं।



6. Example 2: Student Marks के आधार पर Ranking

School या college में marks के आधार पर students को highest से lowest क्रम में दिखाना एक common requirement है।

Data:

Student Marks
Rahul 78
Aman 92
Priya 85
Neha 96
Rohit 72

Formula:

=SORTBY(A2:B6,B2:B6,-1)

Result:

Student Marks
Neha 96
Aman 92
Priya 85
Rahul 78
Rohit 72

यहाँ SORTBY automatically result को spill करता है।



7. Example 3: Multiple Criteria से Sorting

SORTBY की सबसे powerful features में से एक है multiple criteria sorting।

मान लीजिए:

Student Class Marks
Amit 10 85
Rahul 10 92
Neha 9 95
Priya 9 88
Karan 10 92

हमें पहले Class को ascending और फिर Marks को descending order में sort करना है।

Formula:

=SORTBY(A2:C6,B2:B6,1,C2:C6,-1)

यहाँ:

B2:B6 → पहला sorting criterion
1      → ascending

C2:C6 → दूसरा sorting criterion
-1     → descending

यदि दो students की Class समान है, तो उनके Marks के आधार पर आगे sorting होगी।



8. Example 4: Sales Report को Region और Sales के आधार पर Sort करना

मान लीजिए sales team का data है:

Salesperson Region Sales
Amit North 90000
Ravi South 75000
Neha North 120000
Priya South 95000
Karan North 85000

यदि पहले Region को alphabetical order में और प्रत्येक Region के अंदर Sales को highest से lowest रखना है:

=SORTBY(A2:C6,B2:B6,1,C2:C6,-1)

इससे North के employees पहले आएँगे और North के अंदर highest sales वाला employee ऊपर आएगा।

यह technique monthly या regional sales reporting में बहुत उपयोगी है।



9. Example 5: Date के आधार पर Sorting

SORTBY केवल numbers के लिए नहीं है। आप dates को भी sort कर सकते हैं।

मान लीजिए:

Task Due Date
Report 25-Aug-2026
Meeting 22-Aug-2026
Review 30-Aug-2026
Submission 20-Aug-2026

सबसे पहले आने वाली date से sorting:

=SORTBY(A2:B5,B2:B5,1)

Result:

Task Due Date
Submission 20-Aug-2026
Meeting 22-Aug-2026
Report 25-Aug-2026
Review 30-Aug-2026

इसका उपयोग task management, project tracking और deadline reports में किया जा सकता है।



10. Example 6: Product Price को Highest से Lowest Sort करना

E-commerce या inventory report में products को price के आधार पर sort करना common requirement है।

Data:

Product Category Price
Laptop Electronics 65000
Mouse Accessories 800
Monitor Electronics 15000
Keyboard Accessories 1500

Formula:

=SORTBY(A2:C5,C2:C5,-1)

Result:

Product Category Price
Laptop Electronics 65000
Monitor Electronics 15000
Keyboard Accessories 1500
Mouse Accessories 800


11. Example 7: FILTER और SORTBY को साथ में इस्तेमाल करना

यह एक बहुत useful combination है।

मान लीजिए आपके पास:

Product Region Sales
Laptop North 80000
Mobile South 60000
Monitor North 45000
Printer South 30000
Tablet North 70000

हमें केवल North region के products चाहिए और उन्हें Sales के descending order में दिखाना है।

Formula:

=SORTBY(FILTER(A2:C6,B2:B6="North"),FILTER(C2:C6,B2:B6="North"),-1)

यहाँ पहले FILTER केवल North region का data निकालता है और फिर SORTBY उसे Sales के आधार पर sort करता है।

इस प्रकार आप एक dynamic regional sales report बना सकते हैं।



12. Example 8: UNIQUE और SORTBY का उपयोग

मान लीजिए आपके पास employee department data है:

Employee Department
Amit IT
Ravi HR
Neha Finance
Priya IT
Karan HR

अगर आपको unique departments की sorted list चाहिए:

=SORT(UNIQUE(B2:B6))

या SORTBY का उपयोग करते हुए:

=SORTBY(UNIQUE(B2:B6),UNIQUE(B2:B6),1)

Result:

Department

Finance

HR

IT

हालाँकि इस simple case में SORT(UNIQUE()) अधिक सरल है, लेकिन SORTBY तब उपयोगी होता है जब sorting किसी अलग array के आधार पर करनी हो।



13. Example 9: Priority के आधार पर Tasks Sort करना

मान लीजिए project management sheet में Priority दी गई है:

Task Priority
Database Backup High
Email Report Low
Dashboard Update Medium
Data Validation High

अब requirement है:

High → Medium → Low

Alphabetical sorting यहाँ काम नहीं करेगी, क्योंकि alphabetical order में High, Low, Medium आएगा।

इसके लिए हम custom sorting array बना सकते हैं।

Formula:

=SORTBY(A2:B5,XLOOKUP(B2:B5,{"High","Medium","Low"},{1,2,3}))

यहाँ XLOOKUP Priority को numeric order देता है:

High   = 1
Medium = 2
Low    = 3

फिर SORTBY उस numeric array के आधार पर tasks को sort करता है।

यह project management और workflow reports में बहुत उपयोगी technique है।



14. Example 10: Top Sales Employees की Dynamic List

मान लीजिए आपको sales team की पूरी list को highest sales से lowest sales में sort करना है।

=SORTBY(A2:C20,C2:C20,-1)

लेकिन यदि आपको केवल Top 5 चाहिए, तो इसे TAKE के साथ combine किया जा सकता है:

=TAKE(SORTBY(A2:C20,C2:C20,-1),5)

यह formula पहले data को sales के आधार पर descending order में sort करता है और फिर top 5 records निकालता है।

इसका उपयोग:

  • Top 5 Salespersons
  • Top 5 Products
  • Top 5 Customers
  • Top 5 Regions

जैसी reports बनाने में किया जा सकता है।



15. Example 11: Sales के आधार पर Customer List Sort करना

मान लीजिए:

Customer Sales
Customer A 25000
Customer B 85000
Customer C 45000
Customer D 95000
Customer E 65000

Formula:

=SORTBY(A2:B6,B2:B6,-1)

Result:

Customer Sales
Customer D 95000
Customer B 85000
Customer E 65000
Customer C 45000
Customer A 25000

यह customer analysis और sales dashboard में उपयोगी है।



16. Example 12: Horizontal Data को Sort करना

SORTBY vertical data के साथ-साथ horizontal data पर भी काम कर सकता है।

मान लीजिए:


Jan Feb Mar Apr
Sales 50000 30000 80000 60000

अब months को sales के आधार पर ascending order में sort करना है।

Formula:

=SORTBY(B1:E1,B2:E2,1)

Result:

Feb    Jan    Apr    Mar

क्योंकि sales का क्रम:

30,000 → 50,000 → 60,000 → 80,000

इसलिए corresponding months भी उसी order में दिखाई देते हैं।



17. SORTBY और SORT में अंतर

दोनों functions sorting के लिए उपयोग किए जाते हैं, लेकिन उनके उपयोग में महत्वपूर्ण अंतर है।

Feature SORT SORTBY
Basic sorting Yes Yes
Separate sorting array Limited Yes
Multiple criteria Yes Yes
Dynamic array Yes Yes
External/custom sorting array कम flexible अधिक flexible
Complex sorting अच्छा बहुत अच्छा

उदाहरण के लिए:

=SORT(A2:C10,3,-1)

यह तीसरे column के आधार पर sorting करता है।

वहीं:

=SORTBY(A2:C10,F2:F10,-1)

पूरी table को किसी अलग range F2 के आधार पर sort कर सकता है।

यही SORTBY को कई advanced situations में अधिक flexible बनाता है।



18. SORTBY में Dynamic Array का महत्व

SORTBY Dynamic Array functionality का उपयोग करता है।

यदि आप formula लिखते हैं:

=SORTBY(A2:C20,C2:C20,-1)

तो आपको हर row के लिए अलग formula लिखने की आवश्यकता नहीं है।

Excel result को automatically नीचे या आसपास की खाली cells में spill कर देता है।

इससे:

  • formulas कम होते हैं
  • maintenance आसान होता है
  • reports automatically update हो सकती हैं
  • manual sorting की आवश्यकता कम होती है


19. SORTBY में #SPILL! Error

यदि SORTBY formula लगाने के बाद:

#SPILL!

error दिखाई देता है, तो इसका अर्थ सामान्यतः यह होता है कि Excel के पास result को फैलाने के लिए पर्याप्त खाली cells उपलब्ध नहीं हैं।

उदाहरण:

=SORTBY(A2:C20,C2:C20,-1)

यदि formula के नीचे या दाईं ओर कोई existing data है, तो Excel पूरा result spill नहीं कर पाएगा।

Solution

जिस area में result spill होना है, वहाँ मौजूद data हटाएँ।



20. SORTBY में #VALUE! Error

अगर array और by_array की dimensions compatible नहीं हैं, तो समस्या आ सकती है।

उदाहरण:

=SORTBY(A2:C10,E2:E20,1)

यहाँ main array में 9 rows हैं, जबकि sorting array में 17 rows हैं।

इसलिए दोनों ranges को matching rows के साथ रखना चाहिए।

सही उदाहरण:

=SORTBY(A2:C10,E2:E10,1)



21. SORTBY के फायदे

SORTBY के कई महत्वपूर्ण फायदे हैं।

1. Automatic Sorting

Source data बदलने पर result भी automatically update हो सकता है।

2. Multiple Criteria

आप एक ही formula में कई sorting criteria दे सकते हैं।

3. Helper Column की जरूरत कम

कई complex sorting tasks बिना helper column के किए जा सकते हैं।

4. Dynamic Reports

SORTBY को FILTER, UNIQUE, XLOOKUP, TAKE और अन्य functions के साथ combine किया जा सकता है।

5. Dashboard के लिए उपयोगी

Dynamic dashboards में sorted lists automatically generate की जा सकती हैं।



22. SORTBY के Practical Use Cases

SORTBY का उपयोग निम्न situations में किया जा सकता है:

  • Employee salary ranking
  • Student marks ranking
  • Salesperson performance
  • Product sales analysis
  • Customer ranking
  • Inventory price sorting
  • Project task priority
  • Deadline tracking
  • Regional sales reports
  • Top 5 products
  • Top customers
  • Monthly performance
  • Financial reports
  • Dynamic dashboards


23. SORTBY इस्तेमाल करते समय Common Mistakes

Mistake 1: Wrong sort order

Ascending के लिए:

1

Descending के लिए:

-1

का उपयोग करें।

Mistake 2: Range mismatch

array और by_array में corresponding rows या columns compatible होने चाहिए।

Mistake 3: Spill area में data

Dynamic result के रास्ते में data होने पर #SPILL! आ सकता है।

Mistake 4: Dates वास्तव में text हैं

यदि dates text के रूप में stored हैं, तो sorting expected तरीके से नहीं हो सकती।

Mistake 5: Multiple criteria का गलत क्रम

SORTBY में criteria जिस क्रम में दिए जाते हैं, sorting उसी priority के अनुसार होती है।



24. SEO और Reporting के लिए SORTBY क्यों महत्वपूर्ण है?

Modern Excel reporting में users अक्सर चाहते हैं कि report manually sort करने की बजाय automatically update हो।

उदाहरण के लिए एक sales dashboard में आज अगर:

Amit = 50,000
Ravi = 80,000
Neha = 70,000

है, तो SORTBY से ranking automatically:

Ravi
Neha
Amit

हो सकती है।

अगर अगले महीने Amit की sales बढ़कर 100,000 हो जाती है, तो formula automatically नया order दिखा सकता है।

यही automation Excel reporting को अधिक efficient बनाती है।



25. Important SORTBY Formula Examples – Quick Reference

Ascending

=SORTBY(A2:B10,B2:B10,1)

Descending

=SORTBY(A2:B10,B2:B10,-1)

Multiple criteria

=SORTBY(A2:C10,B2:B10,1,C2:C10,-1)

FILTER + SORTBY

=SORTBY(FILTER(A2:C20,B2:B20="North"),FILTER(C2:C20,B2:B20="North"),-1)

TOP 5 + SORTBY

=TAKE(SORTBY(A2:C20,C2:C20,-1),5)

UNIQUE + SORT

=SORT(UNIQUE(B2:B20))



26. निष्कर्ष

Excel का SORTBY function आधुनिक Excel में dynamic और flexible sorting के लिए एक बहुत उपयोगी function है। इसकी मदद से आप किसी range को केवल उसके own columns के आधार पर ही नहीं, बल्कि किसी दूसरे array या range के आधार पर भी sort कर सकते हैं।

इसका basic syntax सरल है:

=SORTBY(array,by_array,[sort_order])

जहाँ 1 ascending और -1 descending sorting के लिए उपयोग किया जाता है।

SORTBY की सबसे महत्वपूर्ण विशेषता इसका multiple criteria sorting है। उदाहरण के लिए आप पहले Region को ascending और फिर Sales को descending order में sort कर सकते हैं।

इसके अलावा SORTBY को FILTER, UNIQUE, XLOOKUP, TAKE जैसे modern Excel functions के साथ combine करके powerful dynamic reports बनाई जा सकती हैं।

यदि आप Excel में sales reports, employee reports, student rankings, customer analysis, inventory reports या dashboards बनाते हैं, तो SORTBY आपकी productivity काफी बढ़ा सकता है।

सबसे महत्वपूर्ण बात यह है कि SORTBY से manual sorting पर निर्भरता कम होती है। एक बार सही formula तैयार करने के बाद Excel source data में होने वाले बदलावों के अनुसार sorted result को automatically update कर सकता है।

इसलिए यदि आप Excel 365 या newer Excel versions का उपयोग करते हैं, तो SORTBY function को सीखना dynamic Excel reporting और data analysis के लिए एक महत्वपूर्ण skill है।



Frequently Asked Questions (FAQs)

क्या SORTBY और SORT एक ही हैं?

नहीं। दोनों sorting के लिए हैं, लेकिन SORTBY किसी अलग array/range को sorting criteria के रूप में उपयोग कर सकता है, इसलिए complex sorting में यह अधिक flexible है।

SORTBY में 1 और -1 का क्या अर्थ है?

1 ascending order और -1 descending order को दर्शाता है।

क्या SORTBY multiple columns के आधार पर sorting कर सकता है?

हाँ। आप एक ही formula में multiple by_array और sort_order arguments दे सकते हैं।

क्या SORTBY automatically update होता है?

हाँ, dynamic-array Excel में source data बदलने पर formula का result भी update हो सकता है।

SORTBY में #SPILL! क्यों आता है?

जब Excel को dynamic result फैलाने के लिए पर्याप्त खाली cells नहीं मिलतीं, तो #SPILL! error आ सकता है।

क्या SORTBY text values को sort कर सकता है?

हाँ। SORTBY numbers, text और dates सहित विभिन्न प्रकार के data को sort कर सकता है।

क्या SORTBY बिना helper column के इस्तेमाल किया जा सकता है?

हाँ। यही इसकी महत्वपूर्ण खूबियों में से एक है। कई advanced sorting tasks सीधे formula से किए जा सकते हैं।

क्या SORTBY Excel के पुराने versions में उपलब्ध है?

SORTBY modern Excel versions की dynamic-array functionality का हिस्सा है। पुराने Excel versions में इसकी उपलब्धता version पर निर्भर करती है।



संक्षेप में:

SORTBY = किसी data range को किसी दूसरे range/array के आधार पर dynamically sort करना।

यदि आप Excel में dynamic reporting, automated ranking और advanced data analysis करना चाहते हैं, तो SORTBY function आपके लिए बेहद उपयोगी है।



👨‍💻 Author

Total Data Solution
Data Analyst | Excel & SAP Analytics Cloud Developer
I share practical Excel, Automation, and Reporting tutorials based on real corporate experience.

एक टिप्पणी भेजें

Please do not enter any spam link in the comment box.

और नया पुराने