Notes BAE
Notes BAE
Business Analytics refers to the practice of using data analysis, statistical methods, and
predictive modelling to gain insights and make informed business decisions. It involves
collecting, processing, and analyzing data to identify trends, patterns, and relationships that
can help organizations optimize their operations, improve performance, and achieve their
strategic goals.
1. Microsoft Excel: Widely used for basic data analysis, visualization, and reporting.
2. Tableau: A powerful tool for data visualization and creating interactive dashboards.
3. Power BI: A Microsoft tool for business intelligence and data visualization.
4. R and Python: Programming languages used for statistical analysis, predictive
modelling, and data manipulation.
5. SAS: A software suite used for advanced analytics, business intelligence, and data
management.
6. Google Analytics: Used primarily for analyzing web traffic and digital marketing
performance.
7. SQL: A language used for querying and managing data in databases.
8. QlikView: A business intelligence tool that provides self-service data visualization.
9. IBM SPSS: Used for statistical analysis and predictive analytics.
10. SAP BusinessObjects: A suite of front-end applications for reporting, data
visualization, and analytics.
These tools enable businesses to analyze data efficiently, generate insights, and support
strategic decision-making processes.
Power Query
Power Query, a data connection technology available in tools like Excel and Power BI,
allows users to perform a variety of data transformations to clean, shape, and analyze data.
Here is an enumeration and description of some common data transformations available in
Power Query:
1. Remove Columns/Rows
Description: Allows you to delete unwanted columns or rows from your data set,
making your data cleaner and more manageable.
Use Case: Removing irrelevant or sensitive information to focus on the data that
matters.
2. Filter Rows
3. Split Columns
Description: Splits a single column into multiple columns based on a delimiter (e.g.,
space, comma) or by fixed number of characters.
Use Case: Dividing a full name into separate first and last name columns.
Go to the Home or Transform tab on the ribbon and click on Split Column. You
will see several options to choose from:
By Delimiter: Split the column based on a specific character or delimiter, such as
commas, spaces, or custom symbols.
By Number of Characters: Split the column into smaller columns based on a
specified number of characters.
By Positions: Split the column at specified positions (e.g., after the 3rd, 7th, and 10th
characters).
By Lowercase to Uppercase: Split when transitioning from a lowercase letter to an
uppercase letter.
By Uppercase to Lowercase: Split when transitioning from an uppercase letter to a
lowercase letter.
By Digit to Non-Digit: Split when transitioning from a number to a letter or other
character, and vice versa.
4. Merge Columns
6. Pivot Columns
Description: Converts unique values from a column into new columns, creating a
wider table format.
Use Case: Turning monthly sales data into a format where each month becomes a
column.
7. Unpivot Columns
Description: Converts columns into rows, effectively reshaping data from a wide
format to a long format.
Use Case: Converting a table with separate columns for each month into a two-
column format with Month and Value.
8. Replace Values
Description: Replaces specific values in a column with new values, useful for
correcting errors or standardizing data.
Use Case: Replacing “n/a” or “N/A” with nulls, or updating outdated product codes.
Description: Changes the data type of columns (e.g., text, number, date) to ensure
that data is interpreted correctly.
Use Case: Converting a column of dates stored as text into a proper date format for
calculations.
Description: Creates new columns using custom calculations with Power Query’s
formula language (M language).
Use Case: Adding a column that calculates the profit margin based on sales and cost
columns.
Description: Flips rows into columns and columns into rows, effectively rotating the
table.
Use Case: Transposing a data table to change its orientation for analysis or
presentation.
Description: Extracts specific parts of data within a column, such as text before or
after a delimiter.
Use Case: Extracting domain names from email addresses.
Description: Fills blank cells with the value from the cell above or below, useful for
carrying values down or up.
Use Case: Filling missing values in a column based on the last known entry.
Description: Combines two or more tables into a single table by appending rows.
Use Case: Merging monthly sales data into a single annual report.
Description: Joins two or more tables based on a common column, similar to SQL
joins (e.g., Inner Join, Outer Join).
Use Case: Merging customer data with order data based on customer ID.
These transformations make Power Query a powerful tool for preparing data, enhancing the
quality of your analysis, and ensuring that your data is in the right shape for reporting and
decision-making.
Concept of Append in Power Query
Append in Power Query is like stacking tables on top of each other. It combines two or more
tables (queries) by adding the rows from each table into one single table. Imagine you have
multiple sheets of data, like sales reports from different months. By appending them, you
merge all the rows into one long table, creating a continuous dataset.
1. Matching Columns:
o Power Query tries to match columns based on their names. If the columns
have the same name in each table, they will align correctly.
o If the column names do not match, Power Query will still append them, but
any unmatched columns will appear with blank values in rows where they
don’t exist.
2. Column Order Doesn’t Matter:
o The order of columns in each table doesn’t need to be the same; only the
names matter. Power Query will align them correctly based on column names.
3. Additional Columns:
o If one table has extra columns not present in the other tables, Power Query
will add those columns to the final table. For rows from tables without those
columns, the new columns will have blank values.
4. Data Types:
o Power Query will use the data type of the first table’s column when
appending. If there are mismatches in data types between tables, Power Query
may convert or adjust data, potentially leading to errors or null values.
5. No Change to Original Tables:
o Append doesn’t alter the original tables; it creates a new combined table. Your
original data remains untouched.
Simple Example
Table 1: Sales data for January (Columns: Date, Product, Sales Amount)
Table 2: Sales data for February (Columns: Date, Product, Sales Amount)
Appending these tables will result in one table with all rows from both January and February
combined into a single, continuous list.
The Append feature is useful for consolidating similar data from multiple sources, making it
easier to analyze and report on combined datasets.
Merging Queries in Power Query
Merging queries in Power Query is similar to performing joins in SQL. It allows you to
combine data from two tables based on a common column. Here’s how you can merge
queries, using the example of emp (employee) and dept (department) tables:
In Excel, go to the “Data” tab and click “Get Data” or “From Table/Range” to open
the Power Query Editor.
Load both tables (emp and dept) into Power Query. You can do this by selecting “Get
Data” and choosing your data source.
Choose the first table (emp) from the Queries pane on the left.
Click on the “Home” tab, then click on “Merge Queries” in the ribbon. You can select
“Merge Queries” or “Merge Queries as New” to create a new query from the merge.
In the Merge dialog box, select the second table (dept) from the dropdown list.
For both tables, select the columns that you want to match on. For example, if both
tables have a column named DeptID, select DeptID in both tables.
Click “OK” to complete the merge. Power Query will combine the tables based on the
selected join type.
After merging, you will see a new column with a table icon in your original table.
Click on the expand icon (an arrow) next to this column to choose which columns
from the second table (dept) you want to include in the merged result.
10. Apply and Close
Once you’re satisfied with the merge, click “Close & Load” to load the combined data
back into Excel.
Here are the different types of merges or joins available in Power Query:
1. Inner Join
o Description: Combines rows where there is a match in both tables.
o Example: You get a list of employees and their departments where both emp
and dept tables have matching DeptID.
o Result: Only employees who have a corresponding department are included.
2. Left Outer Join
o Description: Includes all rows from the first table and matched rows from the
second table. Unmatched rows from the second table will have null values.
o Example: You get a list of all employees and their departments. Employees
without a department will still appear, but the department information will be
null.
o Result: All employees are included, whether or not they have a corresponding
department.
3. Right Outer Join
o Description: Includes all rows from the second table and matched rows from
the first table. Unmatched rows from the first table will have null values.
o Example: You get a list of all departments and their employees. Departments
without employees will still appear, but the employee information will be null.
o Result: All departments are included, whether or not they have employees.
4. Full Outer Join
o Description: Includes all rows from both tables, with matched rows from each
table. Unmatched rows will have null values for missing matches.
o Example: You get a list of all employees and all departments, with nulls
where there is no match in either table.
o Result: Every employee and every department appear in the combined result,
with nulls where there is no match.
5. Anti Join (Left Anti Join)
o Description: Includes rows from the first table where there is no match in the
second table.
o Example: You get a list of employees who do not have a corresponding
department.
o Result: Only employees without a matching department are included.
6. Anti Join (Right Anti Join)
o Description: Includes rows from the second table where there is no match in
the first table.
o Example: You get a list of departments that do not have any employees.
o Result: Only departments without matching employees are included.
Example Summary
emp Table:
dept Table:
DeptID | DeptName
-----------------
10 | Sales
20 | Marketing
40 | IT
By following these steps and understanding the types of joins, you can effectively combine
data from multiple sources in Power Query.