Purpose
The purpose of these queries is to streamline the integration and transformation of marketing and campaign data from multiple sources into a unified format. These Power Query scripts address various types of campaign-related data—ranging from email campaigns, social media posts, and advertising, to events, page performance, and form submissions.
Process
Source Selection:
- The query starts by loading data from the
hbs campaignTraffictable. - myBMT (bmt-dwh-uks-app-my.azurewebsites.net)
Adding a Custom Column (Custom1):
- A new column named
Custom1is added to the table, and each row is assigned a value of0.
Removing Unnecessary Columns:
- The query removes the columns
SourceYear,SourceMonth, andfile_name, as they are not needed for the analysis.
Merging with the Campaigns Table:
- The table is joined with the
Campaignstable, using thesessionCampaignNamecolumn from thehbs campaignTraffictable and theCampaignNamecolumn from theCampaignstable. This is a left outer join, meaning all rows from thehbs campaignTraffictable are kept, and matching rows from theCampaignstable are added.
Expanding the Campaigns Table:
- The
CampaignGuidcolumn from theCampaignstable is expanded and added to the table.
Filtering Rows:
- The query filters out rows where
CampaignGuidis null, keeping only rows with valid campaign data.
Renaming Columns:
- Several columns are renamed to make the dataset clearer:
sessionCampaignNamebecomesNameSourceDatebecomesDate_KeychecksumbecomesObjectID
Changing Column Types:
- The
Date_Keycolumn is changed to thedatedata type for proper formatting.
Unpivoting Data:
- The query unpivots all columns except for
CampaignGuid,ObjectID,Name, andDate_Key. This means all other columns are transformed into two columns:Attribute(which contains the original column names) andValue(which contains the corresponding data).
Adding a Custom Column for Platform:
- A new column named
Platformis added, and all rows are assigned the value"Campaign Traffic"to indicate the data’s context.
Adding a Custom Column for Source Type:
- Another new column named
SourcesTypeis added, and each row is assigned the value"www.bmt.org"to indicate the traffic source.
Result Output:
- The final table, with all the transformations and custom columns added, is returned as the result of the query.
Appended with
This query is an additional step, appending another dataset (hbs campaignTrafficFormSubmissions) to the previous campaign traffic data. Let’s break this down and explain the process.
Power Query Process in Plain English:
- Source Selection:
- The query begins by loading data from the
hbs campaignTrafficFormSubmissionstable. - myBMT (bmt-dwh-uks-app-my.azurewebsites.net)
- The query begins by loading data from the
- Removing Unnecessary Columns:
- It removes the columns
SourceYear,SourceMonth, andfile_name, which are not required for the analysis.
- It removes the columns
- Merging with the Campaigns Table:
- The
sessionCampaignNamecolumn from thehbs campaignTrafficFormSubmissionstable is joined with theCampaignNamecolumn from theCampaignstable through a left outer join. This means all rows from the form submissions table are retained, and matching data from theCampaignstable is brought in.
- The
- Expanding Campaigns Data:
- The
CampaignGuidcolumn from theCampaignstable is expanded and added to the dataset.
- The
- Filtering Rows:
- Rows where
CampaignGuidis null are filtered out, so only rows with valid campaign data remain.
- Rows where
- Renaming Columns:
- Several columns are renamed to align with the dataset:
sessionCampaignNamebecomesNameSourceDatebecomesDate_KeychecksumbecomesObjectIDeventNamebecomesAttributeeventCountbecomesValue
- Several columns are renamed to align with the dataset:
- Changing Column Types:
- The
Date_Keycolumn is changed to thedatedata type for proper formatting.
- The
- Adding a Custom Column for Platform:
- A new column called
Platformis added to the dataset, with all rows given the value"Campaign Traffic"to indicate the data’s context.
- A new column called
- Adding a Custom Column for Source Type:
- Another custom column named
SourcesTypeis added with the value"www.bmt.org"to indicate the traffic source.
- Another custom column named
- Result Output:
- The final processed data is output, ready to be appended to the previous
campaignTrafficdataset.
- The final processed data is output, ready to be appended to the previous
1 thought on “Marketing.CampaignTraffic”