After you map your data, build the Tabular Single Column (TSC) output.
To build the TSC output:
- Print the headers from the metadata response.
- Then, iterate through the combinations of column items and row items.
- Print the page items.
- Print the current combination of header column and row items.
- 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:
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.