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 begins by loading data from the
hbs pagePerformance
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 needed for analysis.
- It removes the columns
- Merging with the
hbs External
Table:- The
pagePath
column from thehbs pagePerformance
table is joined with theUrl - Copy
column from thehbs External
table using a left outer join. This retains all rows from the page performance table, while bringing in any matching rows from thehbs External
table.
- The
- Expanding the
hbs External
Table:- The columns
CampaignGuid
,CampaignId
, andPageViews
from thehbs External
table are expanded and added to the dataset.
- The columns
- Filtering Rows:
- Rows where
CampaignGuid
is null are filtered out, ensuring only rows with valid campaign data are kept.
- Rows where
- Removing Unnecessary Columns (Round 2):
- The
CampaignId
column is removed, as it is not needed for further analysis.
- The
- Unpivoting Data:
- The query unpivots all columns except for
CampaignGuid
,checksum
,SourceDate
, andpagePath
. This means all other columns are transformed into two columns:Attribute
(which contains the original column names) andValue
(which contains the corresponding data).
- The query unpivots all columns except for
- Renaming Columns:
- Several columns are renamed to better reflect their purpose:
checksum
becomesObjectID
pagePath
becomesName
SourceDate
becomesDate_Key
- Several columns are renamed to better reflect their purpose:
- 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 named
Platform
is added, and all rows are assigned the value"Page Performance"
to indicate the context of the data.
- Adding a Custom Column for Source Type:
- Another new column called
SourcesType
is added, with each row receiving the value"www.bmt.org"
to indicate the traffic source.
- Result Output:
- The final table, with all transformations and custom columns, is returned as the result of the query.
Appended with
Source Selection:
- The query starts by loading data from the
hbs pagePerformanceFormSubmissions
table. - myBMT (bmt-dwh-uks-app-my.azurewebsites.net)
Removing Unnecessary Columns:
- It removes the columns
SourceYear
,SourceMonth
, andfile_name
, which are not required for the analysis.
Merging with the hbs External
Table:
- The
pagePath
column from thehbs pagePerformanceFormSubmissions
table is joined with theUrl - Copy
column from thehbs External
table using a left outer join. This means all rows from the form submissions table are kept, and matching rows from thehbs External
table are added where available.
Expanding the hbs External
Table:
- The columns
CampaignGuid
,CampaignId
, andPageViews
from thehbs External
table are expanded and added to the dataset.
Filtering Rows:
- Rows where
CampaignGuid
is null are filtered out to retain only rows with valid campaign data.
Removing Unnecessary Columns (Round 2):
- The
CampaignId
,landingPage
, andeventName
columns are removed, as they are not required for further analysis.
Unpivoting Data:
- The query unpivots all columns except for
pagePath
,checksum
,SourceDate
, andCampaignGuid
. This means all other columns are transformed into two columns:Attribute
(containing the original column names) andValue
(containing the corresponding data).
Renaming Columns:
- Several columns are renamed to make the dataset more meaningful:
pagePath
becomesName
SourceDate
becomesDate_Key
checksum
becomesObjectID
Changing Column Types:
- The
Date_Key
column is changed to thedate
data type for proper formatting.
Adding a Custom Column for Platform:
- A new column named
Platform
is added, and each row is given the value"Page Performance"
to indicate the context of the data.
Adding a Custom Column for Source Type:
- Another column called
SourcesType
is added, with all rows receiving the value"www.bmt.org"
to indicate the traffic source.
Result Output:
- The final processed data is output after all transformations and column additions.