Sample Tabular Data: Sales Data

Source Notebook

Sales data including customer and transaction information

Details

Sales data of 563 transactions including cost, profit, revenue, region, product and customer.

Examples

Basic Examples (2) 

In[1]:=
ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Sales Data\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Sales Data-Input",
AutoDelete->True]\)]
Out[1]=

Dimensions:

In[2]:=
Dimensions[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Sales Data\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Sales Data-Input",
AutoDelete->True]\)]]
Out[2]=

Column keys and types:

In[3]:=
ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Sales Data\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Sales Data-Input",
AutoDelete->True]\), "ColumnKeys"]
Out[3]=
In[4]:=
ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Sales Data\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Sales Data-Input",
AutoDelete->True]\), "ColumnTypes"]
Out[4]=

Scope & Additional Elements (3) 

Reorder columns to display customer information together:

In[5]:=
ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Sales Data\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Sales Data-Input",
AutoDelete->True]\)][All, {"Customer", "Sector", "Region", "Date", "Product", "Quantity", "Revenue", "Profit", "Cost"}]
Out[5]=

Total revenue for each customer in alphabetical order:

In[6]:=
SortBy[AggregateRows[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Sales Data\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Sales Data-Input",
AutoDelete->True]\)], "TotalRevenue" -> Function[Total[#Revenue]], "Customer"], "Customer"]
Out[6]=

Total revenue for each sector ordered according to the total revenue:

In[7]:=
revenue = ReverseSortBy[AggregateRows[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Sales Data\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Sales Data-Input",
AutoDelete->True]\)], "TotalRevenue" -> Function[Total[#Revenue]], "Sector"], "TotalRevenue"]
Out[7]=

Visualize:

In[8]:=
BarChart[revenue -> "TotalRevenue", ChartStyle -> "SandyTerrain", ChartLabels -> Placed[Normal[revenue[All, "Sector"]], Above, Rotate[#, \[Pi]/2] &]]
Out[8]=

Visualizations (4) 

Total profit for each product in each region:

In[9]:=
tab = PivotTable[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: Sales Data\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: Sales Data-Input",
AutoDelete->True]\)], Function[Total[#Profit]], "Product", "Region"]
Out[9]=
In[10]:=
products = Normal[tab[All, 1]]
Out[10]=

Extract the data for each product:

In[11]:=
data = FromTabular[tab, "RowValues"][[All, 2 ;;]]
Out[11]=

Visualize the profit of each product:

In[12]:=
PieChart[Total /@ DeleteMissing[data, 2], ChartStyle -> "BeachColors",
  ChartLabels -> products, LabelStyle -> {14, Bold}]
Out[12]=

Visualize the profit of each product within each region:

In[13]:=
regions = Rest@ColumnKeys[tab]
Out[13]=
In[14]:=
labeler[v_, {1, c_}, ___] := Placed[Style[regions[[c]], Bold, 14], "RadialCenter"]
labeler[v_, {2, c_}, ___] := Placed[Style[(Flatten@Table[products, 4])[[c]], Bold, 8], "RadialCenter"]
In[15]:=
PieChart[{Total /@ DeleteMissing[Transpose[data], 2], Style[Flatten@Transpose[data], LightGray]}, SectorSpacing -> 0, ChartStyle -> (Directive[ColorData[97, #]] & /@ Range[4]), SectorOrigin -> {Automatic, .3}, LabelingFunction -> labeler, Epilog -> Text[Style["Profit", Bold, 11]], ImagePadding -> 0, ImageSize -> 400]
Out[15]=

Gosia Konwerska, "Sample Tabular Data: Sales Data" from the Wolfram Data Repository (2024)  

Data Resource History

Source Metadata

See Also

Publisher Information