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 Advertising
table. - myBMT (bmt-dwh-uks-app-my.azurewebsites.net)
- The query starts by loading data from the
- Renaming the Date Column:
- The column
Date_live
is renamed toDate_Key
for consistency with other datasets.
- The column
- Changing Data Type:
- The
Date_Key
column is converted to thedate
data type to enable easy date-based analysis.
- The
- Removing Unnecessary Columns:
- Columns such as
Created_By
information (e.g., id, title, email), secret campaign fields, and ad specification data are removed as they are not needed for analysis.
- Columns such as
- Duplicating and Splitting Campaign Name:
- A copy of the
Campaign.lookupValue
column is created asCampaign Name - Copy
. This allows further manipulation of the campaign name. - The
Campaign.lookupValue
is split into multiple columns (Campaign Name.1
,Campaign Name.2
,Campaign Name.3
) using the delimiter ” | “.
- A copy of the
- Adding Custom Columns:
- A custom column
Custom1
is added with a default value of0
. - Another column
Name
is created, combining the values ofPublication.lookupValue
,Advertising_campaign_name
, and the month name ofDate_Key
. This helps form a meaningful concatenation for the name of each advertising campaign.
- A custom column
- Renaming Columns:
- The
Advertising_campaign_name
column is renamed toSourcesType
, indicating the source of the campaign.
- The
- Further Removal of Columns:
- Several columns that are not required for analysis, such as
Modified
,Date_end
, andCampaign.lookupId
, are removed.
- Several columns that are not required for analysis, such as
- Merging with Campaigns Table:
- The advertising data is merged with the
Campaigns
table usingCampaign Name
as the key. TheCampaignGuid
is pulled from theCampaigns
table to enable campaign-based reporting.
- The advertising data is merged with the
- Expanding and Unpivoting Columns:
- The merged table is expanded to include the
CampaignGuid
. - Columns such as
SourcesType
,Name
,Campaign Name
, and other campaign-related columns are unpivoted to create two columns:Attribute
(which stores the original column names), andValue
(which stores the respective data).
- Adding Platform Information:
- A new column
Platform
is added, setting its value as “Advertising” for all rows, identifying that the data pertains to advertising campaigns.
- Removing Unnecessary Columns:
- Finally, redundant columns such as
Campaign Name.2
,Campaign Name.3
,Publication.lookupValue
, and other variations ofCampaign Name
are removed.
- Result Output:
- The resulting table is output after all transformations are applied.
1 thought on “Marketing.Advertising”