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 campaignTraffic
table. - myBMT (bmt-dwh-uks-app-my.azurewebsites.net)
Adding a Custom Column (Custom1
):
- A new column named
Custom1
is 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
Campaigns
table, using thesessionCampaignName
column from thehbs campaignTraffic
table and theCampaignName
column from theCampaigns
table. This is a left outer join, meaning all rows from thehbs campaignTraffic
table are kept, and matching rows from theCampaigns
table are added.
Expanding the Campaigns Table:
- The
CampaignGuid
column from theCampaigns
table is expanded and added to the table.
Filtering Rows:
- The query filters out rows where
CampaignGuid
is null, keeping only rows with valid campaign data.
Renaming Columns:
- Several columns are renamed to make the dataset clearer:
sessionCampaignName
becomesName
SourceDate
becomesDate_Key
checksum
becomesObjectID
Changing Column Types:
- The
Date_Key
column is changed to thedate
data 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
Platform
is 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
SourcesType
is 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 campaignTrafficFormSubmissions
table. - 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
sessionCampaignName
column from thehbs campaignTrafficFormSubmissions
table is joined with theCampaignName
column from theCampaigns
table through a left outer join. This means all rows from the form submissions table are retained, and matching data from theCampaigns
table is brought in.
- The
- Expanding Campaigns Data:
- The
CampaignGuid
column from theCampaigns
table is expanded and added to the dataset.
- The
- Filtering Rows:
- Rows where
CampaignGuid
is 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:
sessionCampaignName
becomesName
SourceDate
becomesDate_Key
checksum
becomesObjectID
eventName
becomesAttribute
eventCount
becomesValue
- Several columns are renamed to align with the dataset:
- Changing Column Types:
- The
Date_Key
column is changed to thedate
data type for proper formatting.
- The
- Adding a Custom Column for Platform:
- A new column called
Platform
is 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
SourcesType
is 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
campaignTraffic
dataset.
- The final processed data is output, ready to be appended to the previous
1 thought on “Marketing.CampaignTraffic”