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 pagePerformancetable. - 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 ExternalTable:- The
pagePathcolumn from thehbs pagePerformancetable is joined with theUrl - Copycolumn from thehbs Externaltable using a left outer join. This retains all rows from the page performance table, while bringing in any matching rows from thehbs Externaltable.
- The
- Expanding the
hbs ExternalTable:- The columns
CampaignGuid,CampaignId, andPageViewsfrom thehbs Externaltable are expanded and added to the dataset.
- The columns
- Filtering Rows:
- Rows where
CampaignGuidis null are filtered out, ensuring only rows with valid campaign data are kept.
- Rows where
- Removing Unnecessary Columns (Round 2):
- The
CampaignIdcolumn 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:
checksumbecomesObjectIDpagePathbecomesNameSourceDatebecomesDate_Key
- Several columns are renamed to better reflect their purpose:
- Changing Column Types:
- The
Date_Keycolumn is changed to thedatedata type for proper formatting.
- The
- Adding a Custom Column for Platform:
- A new column named
Platformis 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
SourcesTypeis 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 pagePerformanceFormSubmissionstable. - 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
pagePathcolumn from thehbs pagePerformanceFormSubmissionstable is joined with theUrl - Copycolumn from thehbs Externaltable using a left outer join. This means all rows from the form submissions table are kept, and matching rows from thehbs Externaltable are added where available.
Expanding the hbs External Table:
- The columns
CampaignGuid,CampaignId, andPageViewsfrom thehbs Externaltable are expanded and added to the dataset.
Filtering Rows:
- Rows where
CampaignGuidis null are filtered out to retain only rows with valid campaign data.
Removing Unnecessary Columns (Round 2):
- The
CampaignId,landingPage, andeventNamecolumns 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:
pagePathbecomesNameSourceDatebecomesDate_KeychecksumbecomesObjectID
Changing Column Types:
- The
Date_Keycolumn is changed to thedatedata type for proper formatting.
Adding a Custom Column for Platform:
- A new column named
Platformis 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
SourcesTypeis 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.