Forum Discussion

Medohh2120's avatar
Medohh2120
Copper Contributor
Mar 01, 2026

unpivot data and handle merged cells without using Power Query (Unpivot_Toolkit)

Hey, guys!!

I’ve been working on a set of functional Excel Lambdas to solve a common headache: transforming "Wide" human-readable data into "Long" database formats without having to open Power Query every time.

=UNPIVOT_PLUS(table, [no_of_cols], [no_of_headers], [attribute_names], [value_name],
 [remove_errors], [remove_blanks],[pad_blanks_with],[pad_errors_with])

Don’t worry about the full list, most use cases only require 5 arguments. I've included a table of default values at the end.

Merged Cell Support: Automatically handles fill-down/fill-right logic for merged headers/columns.

Bonus Helper: SPLIT_INJECT

=SPLIT_INJECT(array, target_indices, delimiter, [ignore_empty], [match_mode], [pad_with])

It targets specific columns, splits them by a delimiter (like TEXTSPLIT), and expands the entire table horizontally while keeping all other columns perfectly stable. Optional arguments match TEXTSPLIT defaults.

Feel free to tear this apart or adapt it for your own edge cases. I’d love to hear how you end up using it!

You can grab both functions from my GitHub Gist https://gist.github.com/Medohh2120/f8553c149684e39bb499249e39f01017.

ArgumentDescriptionDefault Behavior
tableThe array or range of data to unpivot.Required argument (no default)
[no_of_cols]Fixed left columns to keep as identifiers​.1
[no_of_headers]Top rows used as headers, handling merged cells.1
[attribute_names]Header name for the unpivoted attributes ."Attribute"
[value_name]Header name for the unpivoted values."Value"
[remove_errors]Excludes grid rows with formula errors.FALSE
[remove_blanks]Removes grid empty cells and empty strings.TRUE
[pad_blanks_with]Value to substitute for empty cells.Leaves cell blank
[pad_errors_with]Value to substitute for errors.Leaves error as-is

 

No RepliesBe the first to reply