Reshape an Excel table between wide and long formats

작성자: AILesson7 분 소요테스트::ChatGPT검토일: 2026-08-28

빠른 답변

Unpivot or pivot data while protecting record grain, identifiers, null meaning, and aggregation rules. 제공할 내용: Source schema and samples, Target schema and use, Keys, labels, blanks, and aggregation. 예상 결과: A reversible reshape plan with Power Query steps, key checks, and row-count reconciliation.

1

맥락 추가

텍스트는 이 브라우저에 유지됩니다. AILesson Prompts는 이를 모델이나 서버로 보내지 않습니다.

2

프롬프트

채워지지 않은 필드는 플레이스홀더로 표시되므로 프롬프트를 복사하고 편집할 수 있습니다

Design an Excel reshape from wide to long or long to wide using the supplied schema and rules.

Headers, types, grain, keys, measures, samples, blanks, and errors:
[source]

Target orientation, columns, order, downstream use, refresh, and reversibility:
[target]

Unique keys, label parsing, null/zero, duplicates, units, totals, aggregation, and validation:
[rules]

State the source and target record grain before proposing steps. For wide-to-long, separate identifier columns from measure columns and define how original headers become attribute fields; do not unpivot totals or notes accidentally. For long-to-wide, prove that each row-key and new-column combination is unique or apply only an explicitly approved aggregation. Preserve null versus zero, data types, units, and source labels. Prefer Power Query for refreshable transformations and provide menu-level steps plus key M operations when useful; use formulas only if the stated environment warrants them. Return: grain and key audit; source-to-target mapping; transformation steps; duplicate and header-parsing policy; expected row/column reconciliation; validation queries; sample output; refresh/reversal notes; and failure conditions that should stop the reshape.
Playground에서 사용해 보기
기본적으로 비공개프롬프트 구성은 브라우저에서 로컬로 이루어집니다. 조직에서 허용하지 않는 한 기밀 정보를 AI 서비스에 입력하지 마세요.

입력에서 결과까지

적용 예시

구체적인 맥락이 이 레시피를 바로 사용할 수 있는 결과로 바꾸는 방법을 확인하세요

실제 입력

Source schema and samples
Excel Table QuarterlyTargets, one row per Product ID + Region. Columns: Product ID text, Region text, Owner text, Q1 Target whole number, Q2 Target whole number, Q3 Target whole number, Q4 Target whole number, Annual Total formula, Notes text. 120 rows. Product ID + Region is unique. Q2 may be blank meaning target not set; zero means explicitly no target. No formula errors. Example P-01, East, Ana, 100, blank, 0, 140, 240, launch delayed.
Target schema and use
Wide to long for Power BI. Target columns Product ID, Region, Owner, Quarter, Target, Notes. One row per product-region-quarter, keeping blank target rows so missingness can be analyzed. Refresh monthly from the Excel Table. Annual Total must not become a quarter. Reversal to original four quarter columns should be possible, but Annual Total may be recalculated.
Keys, labels, blanks, and aggregation
Quarter headers must map exactly Q1 Target -> Q1 through Q4 Target -> Q4. Do not aggregate. Product ID + Region + Quarter must be unique. Preserve Target as nullable whole number and zero as zero. Owner and Notes repeat across quarter rows. Validate 120×4=480 rows and exactly four quarters per source key.

예시 출력

Grain audit: source key is Product ID + Region; target key is Product ID + Region + Quarter. Owner and Notes are descriptive attributes repeated by design. Annual Total is derived metadata and excluded from unpivot. Expected target is exactly 480 rows, including null targets.

Power Query steps: load QuarterlyTargets with Data > From Table/Range. Set Product ID, Region, Owner, Notes to text; Q1–Q4 Target to nullable whole number. Select Product ID, Region, Owner, Annual Total, Notes, then choose Unpivot Other Columns only after confirming the “other” set is exactly the four quarter columns; a safer refresh-resistant approach is explicitly select Q1 Target through Q4 Target and choose Unpivot Columns. Rename Attribute to Quarter Source and Value to Target. Map the four allowed header values to Q1–Q4; if any other value appears, return an error rather than trimming arbitrary text. Remove Annual Total after retaining it only for reconciliation, then order target columns. Do not filter null Target rows.

Validation: group by Product ID, Region, Quarter and stop if any count differs from 1. Group by source key and require four rows. Require row count 480, allowed Quarter set Q1–Q4, and whole-number-or-null Target. Recalculate non-null quarterly sum and compare with source Annual Total while treating null as missing, not automatically zero; for P-01 the long rows are Q1=100, Q2=null, Q3=0, Q4=140, with Owner Ana and Notes repeated. Reverse by pivoting Quarter using Target only after uniqueness passes and “Don't Aggregate” is available; recalculate Annual Total under an approved null rule.

효과가 있는 이유

  1. 1

    Declaring grain before reshaping prevents repeated-looking rows from being mistaken for duplicates.

  2. 2

    Row-count and key reconciliation detects dropped measures, accidental totals, and unauthorized aggregation.

결과 확인

  • Are identifier, measure, metadata, total, and note columns classified before transformation?

  • Is every long-to-wide row-key/column-key combination unique or explicitly aggregated?

  • Do source and target reconcile for keys, non-null measures, zeros, totals, and units?

안심하고 사용하세요

자주 묻는 질문

이 레시피를 언제 사용해야 하는지, 무엇을 제공해야 하는지, 그리고 어떤 부분에서 사람의 검토가 여전히 중요한지에 대한 실용적인 답변

What should I prepare before using “Reshape an Excel table between wide and long formats”?

For “Reshape an Excel table between wide and long formats,” prepare Source schema and samples, Target schema and use, and Keys, labels, blanks, and aggregation. Replace placeholders only with information you can verify. If a detail is unknown, preserve that uncertainty explicitly instead of asking the model to infer it.

When is the “Reshape an Excel table between wide and long formats” result not ready to use?

The result is not ready if it does not yet deliver the stated outcome—A reversible reshape plan with Power Query steps, key checks, and row-count reconciliation—from the supplied evidence, or if it relies on unresolved assumptions, missing approvals, or invented details. Use the checks as release gates: revise the source inputs or assign a named, authorized reviewer instead of polishing an unsupported output.

Which AI tools have recorded tests for “Reshape an Excel table between wide and long formats”?

The published test record for “Reshape an Excel table between wide and long formats” lists ChatGPT as of 2026-08-28. This confirms recorded runs, not guaranteed compatibility or identical results in later product versions. For another tool or version, keep every constraint visible and repeat the result checks before use.

더 많은 탐색 방법

이 레시피가 적합한 상황

작업을 계속 진행하세요