After you map your data, build the Tabular Single Column (TSC) output.

To build the TSC output:

  1. Print the headers from the metadata response.
  2. Then, iterate through the combinations of column items and row items.
  3. Print the page items.
  4. Print the current combination of header column and row items.
  5. Print the cell value at the current index.

With the data mapped, we now create the new output. We print the first line that contains the headers retrieved from the metadata response:

Time,Products,Organization,Line Items,Value

Next, we iterate through every combination of mappings in ColumnItems x RowItems (1,1 → UK, Units Sold ; 2,1 → France, Units Sold; … ), print the PageItems, followed by the current combination of column and row items, and finally the cell value at the current index.

We must ensure that the order of printing the dimensions in the headers line matches the order of printing their respective dimension items.  The empty axes must not add any extra columns. The final output is:

Time  ,Products,Organization ,Line Items,Value
Jan 14,Apples  ,UK           ,Units Sold,10
Jan 14,Apples  ,France       ,Units Sold,20
Jan 14,Apples  ,Germany      ,Units Sold,30
Jan 14,Apples  ,Total Company,Units Sold,60
Jan 14,Apples  ,UK           ,Produced  ,100
Jan 14,Apples  ,France       ,Produced  ,200
Jan 14,Apples  ,Germany      ,Produced  ,300
Jan 14,Apples  ,Total Company,Produced  ,600

Whitespace is added to the output for readability.