
In many Excel scenarios, you may need to rank only specific rows based on a condition.
This becomes more complex when duplicate scores exist and additional tie-break rules are required.
In this tutorial, you will learn how to rank only selected records using Power Query.
Tie-breaking is handled automatically using a secondary column such as count.
The ranking updates dynamically whenever the data is refreshed.
엑셀에서 순위를 구할 때
전체가 아니라 특정 대상자만 따로 순위를 구해야 하는 경우가 있습니다.
예를 들어
대상여부가 1인 행만 대상으로 순위 계산
성적이 높은 순서대로 정렬
성적이 같으면 건수로 다시 순위 결정
이런 조건이 들어가면 수식이 금방 복잡해집니다.
이번 글에서는 Power Query를 이용해서
대상여부가 1인 행만 따로 순위를 매기고, 그 결과를 다시 원본표에 붙이는 방법을 정리해보겠습니다.
문제 상황
원본 데이터에는 다음과 같은 열이 있습니다.
건
성적
순위
대상여부
여기서 원하는 것은
대상여부가 1인 행만 따로 추출
성적 내림차순 정렬
성적이 같으면 건 내림차순 정렬
그 순서대로 대상순위 생성
다시 원본 데이터에 대상순위를 붙이기
해결 방법
이번 작업은 Power Query UI만으로 해결했습니다.
흐름은 아주 단순합니다.
원본 데이터에 인덱스 추가
대상여부 = 1만 필터
성적 내림차순 정렬
건 내림차순 정렬
인덱스 추가로 대상순위 만들기
원본과 병합
대상순위 열 확장
이렇게 하면 원본 구조는 유지하면서
대상자만 별도로 계산한 순위를 쉽게 붙일 수 있습니다.
결과
대상여부가 1인 행만 대상순위 표시
대상이 아닌 행은 빈값 또는 null 유지
데이터가 추가되어도 새로고침만 하면 자동 반영
즉, 복잡한 수식 없이도
UI만으로 충분히 자동화가 가능합니다.
핵심 포인트
대상자만 따로 계산하려면 먼저 필터
동점 처리 기준은 정렬 순서로 해결
다시 원본에 붙일 때는 인덱스 병합 사용
이번 방법은 순위 문제뿐 아니라
특정 조건 대상만 따로 계산한 뒤
원본에 다시 붙이는 다양한 작업에도 그대로 응용할 수 있습니다.

videolink - https://youtu.be/h_jOpGtvBG0
Download the sample file below.
You can download the zip file in [자료실][Download] page
The file name is 42.대상순위(conditional rank).
Use the English M code provided for your dataset.
✔ Download the ready-to-use Power Query template below
✔ Just copy and paste the M code – works instantly
The original sample file is based on a Korean dataset.
You can apply the English M code to adapt it to your own data.
--------------------------------
Need a custom automation for your Excel workflow?
I can build a tailored solution based on your data.
✔ Used in real-world business automation
✔ Saves hours of manual work
minbedata@gmail.com
You can pay via PayPal.
You can also contact me via Upwork for secure payment and project handling.
<a href="https://www.upwork.com/freelancers/~01eb52dbd212cffc17" target="_blank">
Hire me on Upwork
</a>
You don't worry about conversing with me.
My Major is an English literature, so I can speak English fluently and read, listening, writing proficiently
korean version web address (한국버전) is
<a href="https://blog.naver.com/minbe-data" target="_blank">네이버 블로그 바로가기</a>