I am trying to visualize advertisement data from amazon which is comprised of a dozen or so campaigns, each of which has three subgroups and each subgroup has its own performance data (metrics). Specifically, for any campaign, it has three types of placement data (search types), product placement (PP), rest of search (RoS), and top of search (top), and each of these placement types has metric performance data (sales, clicks, spend, etc.). There are also three different types of campaign, manual, auto, and branded, for which the hierarchical structure above applies. I want to import the data from amazon as an excel file and create two interactive plots in which you can pick what's being plotted on each axis. In the first type of plot, I want to use a bar chart to compare different campaigns (campaign type and placement/search types) and some specific N metric. I planned to use manipulate to use a dropdown menu to pick the metric, placement type, and campaign type for a specified time period to compare. The second type of plot I want to make is a list plot of one metric in one campaign over a period of time. The data for all metrics of all campaigns would be entered weekly. To be clear, the menus are choosing which data to display.

Here is a rough sketch of what I want to do, as well as a visual representation of how the data is structured in case my explanation was poor/confusing. Data Structure

End Goal Graph Example

Here is what the raw data looks like in excel, and after being imported into mathematica: Ex Mathematica Data

TLDR: I have data organized as laid out in the first example and I want to create interactive graphs that substitute datasets to achieve the plots in the second picture. How should I organize and sort my raw data? Is manipulate the correct approach? So far I have split up my data by search type (PP, Top, RoS) but not by campaign types (auto, manual, brand) by creating separate arrays for each search type metric (PPimpressions, PPclicks, RoSclicks, etc.) by using the part command from the original imported dataset, and used barchart and manipulate to interchange the datasets. However, when picking the metric to be plotted from the manipulate menu, it displays the raw data instead of the variable I named it as, how can I make it so that it displays the name of the variable not the array values?

I'm not looking for someone to do this for me (but that would be great), I'm just looking for someone to point me in the right direction, as I feel that my current approach is not the best. What's the best way to organize the data so that it can be used how I want it to? I want to set it up so that I can add data every week and view any dataset at any time, compared to other campaigns or itself over some specified time period (The data provided is an example of one week's worth of data). Is this even possible? Thank you for taking the time to read this and help me out, I greatly appreciate it.


1 Answer 1


I would pack the data into associations like:

manualPlacement = 
   "PP" -> Association[week1 -> metrics, week2 -> metrics, ..], 
   "Ros" -> Association[week1 -> metrics, ..], 
   "Top" -> Association[week1 -> metrics, ..]];
autoPlacement = Association["PP" -> .., "Ros" -> .., "Top" -> ..];
brandedPlacement = Association["PP" -> .., "Ros" -> .., "Top" -> ..];
campign = 
 Association["ManualCampign" -> manualPlacement, 
  "AutoCampign" -> autoPlacement "BrandedCampign" -> brandedPlacement]

where metrics may be a list with your numbers. You can the retrive the data e.g. by:

campign["ManualCampign", "PP", week1]
  • $\begingroup$ Hey thanks for getting back to me. How could I make it so that within week 1 there is another set of associations for specific metrics and their subsequent data set? For example, I'd want to access the number of orders within week 1 of a manual PP campaign, would I just add another layer of associations within week 1? $\endgroup$ Oct 20, 2020 at 4:08
  • $\begingroup$ You are right, you just add another layer and you would then retrieve the data by: campign["ManualCampign", "PP", week1, metric1] where week1 and metric1 are the keys you have chosen. $\endgroup$ Oct 20, 2020 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.