
Why Excel Drops Leading Zeros When You Open a CSV File
Why Excel turns 00123 into 123 when you double-click a CSV, what is lost on save, and how to keep zeros with the import wizard, Power Query or text columns.
Tag
45 posts

Why Excel turns 00123 into 123 when you double-click a CSV, what is lost on save, and how to keep zeros with the import wizard, Power Query or text columns.

How to open, edit and save CSV files in Excel, Google Sheets and LibreOffice without losing zeros, digits, dates or accents: imports, settings, traps.

Compare Excel PERCENTILE.INC, PERCENTILE.EXC and MEDIAN with PostgreSQL percentile_cont and percentile_disc, with worked numbers.

Split delimited text into columns or rows in Excel with TEXTSPLIT and Text to Columns and in PostgreSQL with split_part, string_to_array and unnest.

Join text with a separator in Excel using TEXTJOIN and the ampersand and in SQL with concat_ws and string_agg, with blanks, NULLs and order handled.

Compare Excel approximate match lookups with SQL range joins for tiers, rates and bands: how each handles gaps, boundaries and overlaps, and which to use.

Count distinct customers per month in Excel with UNIQUE and FILTER, SUMPRODUCT or a PivotTable, and in SQL with COUNT(DISTINCT), with blanks handled.

Remove duplicate rows but keep the latest per key, in Excel with sort and Remove Duplicates, XLOOKUP or SORTBY, and in SQL with DISTINCT ON or ROW_NUMBER.

Rank customers by spend with RANK.EQ and sorted lists in Excel and with RANK, DENSE_RANK and ROW_NUMBER in SQL, including ties, top N and ranks per group.

Build a monthly running total in Excel with expanding ranges, SUMIFS and SCAN, and in SQL with a window function, including ties and resets.

Join two sheets on two keys in Excel with XLOOKUP, SUMIFS or Power Query, and in SQL with a two-column join, handling duplicates, NULLs and missing matches.

Find the second highest value in Excel with LARGE and MAXIFS and in SQL with OFFSET, DENSE_RANK and subqueries, and decide how ties and NULLs should count.