Importing Data in Depth

Sales Data Custom Commands

Most files import with the window alone, as Importing Sales Data shows. For the rest, a sales data interface can carry custom commands: short instructions that find columns by their headings, tidy product codes, match periods by their words, scale figures, work figures out, and add up weekly or store-level files.

Where they go

Custom commands belong to a saved interface. So set the import up in the window first, and save it with Import & Save Interface. Then:

  1. Open Tools › Settings and expand Sales Data Interfaces.
  2. On the interface's row, click the ... button under Custom Commands. The number beside it is how many it has.
  3. Click the green plus to add a line, and fill in its Command, Parameter 1 and Parameter 2. Leave a parameter empty when a command doesn't need it.
  4. Save the settings. The commands apply the next time the interface runs, with Open or Load Data.

The arrows change the order, the red cross deletes a line, and the plus on a line inserts one below it. Order matters for some commands, as this page says where it does.

Type the names exactly as they are here, capital letters included. Some commands accept other spellings, but not all do, and a command Spanner doesn't recognise is ignored without a word. This page is for Spanner 2.5.1.2; where earlier versions differ, it says so.
Sales Data Interfaces in Settings with the Demo interface's Custom Commands list open: seven Import Calculate commands, filling PRICE with VALUE/UNITS, VOLPRICE with VALUE/VOLUME, UNTROSN with UNTROSW*(WTD/NUM), VALROSW with UNTROSW*PRICE, VALROSN with UNTROSN*PRICE, VOLROSW with VALROSW/VOLPRICE and VOLROSN with VALROSN/VOLPRICE, each line with arrows, a red cross and a green plus
The Demo interface's seven custom commands, opened from Custom Commands. They are its import calculations, in the order they run: price first, as later lines use it.

Finding columns by heading

A saved interface remembers columns by their letters and rows by their numbers. If the file's columns move from one month to the next, have Spanner find them by their headings instead. It looks in the first 50 rows of the first sheet it imports, when the file is read.

CommandParametersWhat it does
ID Code1: the headingThe Product ID column is the one whose heading is exactly this, such as Product Code.
Description1: the headingThe Product Name column, in the same way.
Measure Row, Measure Column1: some text
2: optional, more text
The measures are in the row, or the column, of the first cell that contains either text.
Time Row, Time Column1, 2: as aboveThe time headings, in the same way.
Time2 Row, Time2 Column1, 2: as aboveThe second time row, when the length and the year are on two rows.
Outlet Row, Outlet Column1, 2: outlet names, separated by spacesThe outlets, in the same way. Write a space inside a name as <sp>: Retailer<sp>A.
Move Header Text1: Measure to Time
2: the text
Moves text from the measure headings to the time headings. For headings such as Units and Units Year Ago over periods such as 52 weeks: Parameter 2 Year Ago, with its space, leaves Units as the measure twice, and the time headings become 52 weeks and 52 weeks Year Ago. Headings in rows only; only the first such command is used.

Product codes

These change the file's product codes before they are matched to your products. They change nothing in your document. Only one of them is used: if there are several, the first in this table wins.

CommandWhat it does to the file's codes
Check DigitAdds the missing last digit to codes of 7 or 12 digits, so they match full 8 and 13 digit barcodes.
IRI2UPCTurns Circana (IRI) product codes into barcodes.
IRI2UPC813As IRI2UPC, then short barcodes back to 8 digits.
IRI2UPC13As IRI2UPC, then zeros added to the front to make 13 digits.
UPC13Adds zeros to the front of codes shorter than 13 characters.
UPC813Codes shorter than 8 become 8 digits, and those of 8 to 12 become 13.
ID = DescFor a file with no codes: each row's product name, from the Product Name columns, becomes its code. Product ID must still be set to a column: give it the name column.

Since 2.5.1.0 Spanner already adds zeros to the front of barcodes to compare them, so UPC13 and UPC813 are seldom needed now. Check Digit and the Circana commands still are.

Match To

CommandParametersWhat it does
Match To1: a classification's headingAfter the usual matching, matches the products still unmatched whose value in that classification is exactly the file's code. For a retailer's code that you keep in a classification rather than in Matches.

A match made this way is stored in the product's Matches too, when Update Product Matches is ticked, so the next import finds it in the usual way.

Matching outlets

CommandParametersWhat it does
Outlet Match1: AllEvery outlet in the file that isn't matched goes into the document's outlet of the same name, which is added if the document hasn't got it.
Outlet Match1: All Except
2: outlet names, separated by spaces
The same, leaving out the outlets named. Write a space inside a name as <sp>.

Use it for a file whose list of retailers or markets changes from time to time, so new ones come in without opening the window.

Matching periods by their words

A saved interface remembers each time heading's match by its exact text. When the headings carry dates, next month's file doesn't match. Time Match commands match periods by words that stay the same instead. They work on the time headings still unmatched.

CommandParametersWhat it does
Time Match1: 1
2: some text
Headings that contain the text are Time 1.
Time Match1: 2
2: some text
Headings that contain the text are Time 2.
Time Match1: TY
2: some text
Headings that contain the text are the latest year.
Time Match1: YA
2: some text
Headings that contain the text are the previous year.
Time Match1: Delete
2: some text
Takes the text out of the headings before Spanner looks for dates in them.
Time Match Replace1: text to find
2: text to put in its place
The same, putting other text in its place.

A heading is matched when it has both a length and a year. Each period goes to one heading only. For example, with the made-up headings Latest 52 Weeks, Year Ago 52 Weeks, Latest 12 Weeks and Year Ago 12 Weeks:

CommandParameter 1Parameter 2
Time Match152 Weeks
Time Match212 Weeks
Time MatchTYLatest
Time MatchYAYear Ago

When the headings give only the length, and a date, such as 52 w/e 05/10/25 and 52 w/e 06/10/24: match the lengths with 1 and 2, and use Delete to take out 52 w/e and 12 w/e , leaving the dates. Spanner then takes the earlier of the two dates as the previous year and the later as the latest. Dates are read as your computer writes them, so a UK computer reads 05/10/25 as 5 October 2025.

Scaling

These multiply the figures as they come in: by 1000 for a file in thousands, or by 0.01 for percentages written as 45 that your document holds as 0.45.

CommandParametersWhat it does
Measure Scale1: a measure code, such as VALUE
2: the number to multiply by
Scales that measure in every outlet and period.
Time Scale1: the periods
2: the number
Scales every measure in the periods named: 1 or Time 1; 2 or Time 2; TY or Latest; YA, LY or Previous; or one period, 1L (or Time 1 Latest), 1P, 2L, 2P.
Measure Time Scale1: a measure code, a space and a period: VALUE 1TY; the periods are 1TY, 1LY, 2TY, 2LY
2: the number
Scales one measure in one period.

The three kinds multiply together. Two of the same kind for the same thing don't: the later one replaces the earlier. Before 2.5.1.2, Time Scale ignored 1, scaled Time 1 for 2, and scaled the latest year for YA, LY and Previous; with those versions, use Time 1, Time 2 or the single periods.

Calculations

The Import Calculations of the window's second tab (see Importing Sales Data) are saved as custom commands too, one for each line, in the order they run:

CommandParametersWhat it does
Import Calculate1: the measure to fill, by its code
2: the formula
Works the measure out for each imported product, in each outlet and period the file has.

Formulas use measure codes, numbers, + - * / and full brackets: each operator joins two things, so write (A-B)-C, never A-B-C, and (0-A) for a minus sign.

Totals of the file

A formula can also use a total over every product in the file, for the same outlet and period: put sum, ave, max, min or count straight in front of a measure code. For example, a measure for each product's share of the file's value sales:

CommandParameter 1Parameter 2
Import CalculateSHARE(VALUE/sumVALUE)*100

The totals take in every row of the file, matched to a product or not, and are added up before any scaling. The document needs the measure to fill, here one with the code SHARE.

Temporary measures and copying

Some files put a figure where Spanner can't take it directly: last year's sales as a second measure, for instance, beside this year's, under one period. A temporary measure takes it in, and Copy After moves it to where it belongs.

CommandParametersWhat it does
Temp Measure1: a code, a space and a description: TEMP2 Sales Last Year
2: optional, a calculation
Adds a measure to the document while the interface runs, and takes it away after the import. Match the file's heading to it as to any measure.
Copy After1: the figures to copy
2: where to copy them
After the import, copies figures from one measure, outlet and period to another, for every product in the document.

Copy After's parameters are sales codes of four parts joined by _: measure, outlet, length and year.

  • Outlet: * for every outlet, OU for the selected planogram's outlet, CH for its channel, or an outlet's name.
  • Length: 1, 2 or * for both.
  • Year: TY, YA or * for both.

Both codes must cover the same number of outlets, lengths and years. For the example above: match Sales This Year to Value and Sales Last Year to TEMP2, with Time fixed at Time 1 latest, then:

CommandParameter 1Parameter 2
Temp MeasureTEMP2 Sales Last Year
Copy AfterTEMP2_*_1_TYVALUE_*_1_YA

Several Copy After commands run in their order. Before 2.5.1.2 only the last one ran, and an outlet named on the copying-to side was taken as the copying-from side's outlet: with those versions, use one Copy After with *, OU or CH there. For headings in rows, Move Header Text is often simpler.

Adding products

With Add Unmatched Products ticked, every row of the file that finds no product becomes a new product. Add Criteria limits that to the rows that sell. The Criteria box in the window (see Importing Sales Data) edits these same commands.

CommandParametersWhat it does
Add Criteria1: a sales code, such as VALUE_*_*_*
2: one or more conditions, such as >0
Adds a product only if one of its figures for that code meets the conditions.
  • The sales code has the four parts of Copy After's, with two more choices for the outlet: OUCH for the selected planogram's outlet and channel, and a number for the outlet's place in the document's list, counting from 0. OU, CH and OUCH need a planogram selected.
  • The conditions are >, >=, <, <= or = and a number, such as >=1000. Separate several with spaces: >=1000 <=50000. Each is checked on its own, so with a * in the code, one outlet or period can meet one condition and another the next.
  • Several Add Criteria commands must all be met.

For example, VALUE_*_1_TY and >=1000 adds the products that sold at least 1000 in some outlet in the latest Time 1. Criteria only decide which new products are added; matched products always get their figures. Rows you tick to add in the window's Match to Excel list skip the criteria: see Importing Sales Data. Before 2.5.1.2, products were only added with the Update Data option.

Weekly figures into longer periods

A retailer's portal often gives a column for each week. Spanner can add the weeks up into its four periods as the file comes in: the latest 52 weeks, the 52 before them, and so on. The time headings must be along one row or down one column of their own, not shared with measures or outlets.

It works in three stages. Each time heading has a working copy that the first commands tidy into a date; the grouping commands then pick the weeks for each period by their dates; and Aggregate says how to add each measure up.

1. Tidy the headings into dates

These run in their order, on the working copy only.

CommandParametersKeeps
Time After1: some text
2: optional, incl
What follows the text; with incl, the text too.
Time Before1: some text
2: optional, incl
What comes before the text; with incl, the text too.
Time Left, Time Right1: a number of charactersThat many characters from the left, or the right.
Time Mid1: where to start, counting from 0
2: how many
Characters from the middle.
Time Substitute1: text to find
2: text to put in its place
The heading, with the text replaced.
Time Date ValueReads what is left as a date, such as 05/10/2025, in your computer's date order.
Time ValueReads what is left as Excel's number for a date, such as 45935.

2. Group the weeks

Each names a period as 1L, 1P, 2L or 2P, and each period can have one group.

CommandParametersTakes
Time Group Last1: how many weeks
2: the period
The latest weeks, by date.
Time Group First1: how many weeks
2: the period
The earliest weeks.
Time Group Mid1: weeks to skip, a space, and how many to take: 40 12
2: the period
Weeks from the middle: skip the earliest, then take.
Time Group Column1: two column letters: C BB
2: the period
The weeks in those columns, for headings along a row. Put it before any command that tidies the headings.

3. Say how to add up each measure

CommandParametersWhat it does
Aggregate1: a measure code
2: Sum, Sum>0, Average, Average>0, Count or Count>0
How the weeks of each group become one figure. >0 leaves out weeks with nothing. A measure with no Aggregate command has no figures in the grouped periods.

Use Sum for sales, and Average or Average>0 for distribution or price. In the second tab, the groups appear as headings such as Σ52 Weeks Latest, already matched to their periods; match the measures as usual.

For example, a made-up file with 104 weekly columns headed w/e 05/10/2025 and so on along row 2, under Value and Units in row 1:

CommandParameter 1Parameter 2
Time Afterw/e 
Time Date Value
Time Group Last521L
Time Group First521P
Time Group Last122L
Time Group Mid40 122P
AggregateVALUESum
AggregateUNITSSum

Time 1 is the latest 52 weeks and the 52 before them; Time 2 is the latest 12 weeks, and the 12 weeks a year before them, which are weeks 41 to 52 counting from the earliest. The document's Time 1 and Time 2 should say 52 and 12.

Before 2.5.1.2, grouping only worked the first time the headings were read: going back to the second tab and on again, or Spanner AI's second step, lost the groups. From 2.5.1.2 the file is read afresh each time.

Adding outlets together

A file of stores, or of a retailer's formats, can be added up into fewer outlets as it comes in. The outlet headings must be along one row or down one column of their own. It works as weekly grouping does: each outlet heading has a working copy, the commands change it, and outlets whose working copies end up the same are added together under that name.

CommandParametersWhat it does
Outlet Group1: a nameTurns grouping on. Outlets that no other command changes are added together under this name; without a name, Grouped Outlets.
Outlet Contains1: some text
2: a name
Outlets whose name contains the text are added together under the name.
Outlet Substitute1: text to find
2: text to put in its place
Changes the working copy, so outlets that then read the same go together.
Aggregate1: a measure code
2: how
As for weekly figures: one for each measure.

For example, with made-up stores Express 0123, Express 0456 and Superstore 0789:

CommandParameter 1Parameter 2
Outlet GroupSupermarkets
Outlet ContainsExpressConvenience
AggregateVALUESum

The two Express stores are added up as Convenience, and the superstore, which nothing changed, as Supermarkets. In the second tab, match those two to outlets in the document, as in Importing Sales Data.

Other commands

CommandParametersWhat it does
No DataRuns the import without writing any figures: only the match codes and the classification columns. Useful to store a file's codes on your products, or to code products from a sales file.
No IgnoredDoesn't read the sheets the interface leaves out at all, rather than reading and then ignoring them. Quicker for a large workbook with many sheets.
Update Library MatchesAfter the import, writes the match codes it stored on your products to the product library each product came from, so other documents have them. The library needs a Matches column. Needs Update Product Matches ticked, from 2.5.1.2.
pre: or post: and an automation command, such as post:Calculate1, 2: that command's parametersRuns the automation command before or after the import. See the automation reference.

Spanner has a few more commands, for working figures out across grouped outlets and periods, which very few files need. If a file still won't import, ask us.

Ask Spanner AI

Spanner AI knows these commands, and adds them to an import when the file needs them: finding columns by heading, product codes and Match To, matching outlets and periods, scaling, calculations and totals of the file, temporary measures, copying, adding products, and weekly or outlet grouping. Grouping through Spanner AI needs Spanner 2.5.1.2 or later.

For example, ask:
  • "The barcodes in this file have lost their last digit. Can you still match them?"
  • "The file is in thousands: scale value sales up as it comes in."
  • "Match the periods by their words, so the import still works next month."
  • "Work out price from value and units as the file comes in."
  • "This file has a column for each week. Add them up into the latest 52 and 12 weeks and the year before."

A file that won't import?

Send us a sample, with the figures changed if you like, and we'll set the interface up with you.

Email us Book a Demo