Prabhu, Punit - Data Analytics With Excel (2021)
Prabhu, Punit - Data Analytics With Excel (2021)
WITH EXCEL
Punit Prabhu
Copyright © 2021 Punit Prabhu
The characters and events portrayed in this book are fictitious. Any similarity to real persons, living or
dead, is coincidental and not intended by the author.
No part of this book may be reproduced, or stored in a retrieval system, or transmitted in any form or
by any means, electronic, mechanical, photocopying, recording, or otherwise, without express written
permission of the publisher.
CONTENTS
Introduction to Data Analytics
Introduction of Software to be used in the course
Basics & Navigation
Formulas & Functions
Formatting
Pivot Table & Slicer
Power Query
Power Pivot
Charts & Dashboard
Practice Files Link
INTRODUCTION TO DATA
ANALYTICS
What is Data Analytics?
Data Analytics is the process of exploring and analyzing large data sets to
help data driven decision making.
Analyze Data
Decision Making
Definition
Data when suitably filtered and analysed along with other related
Data
Sources and a suitable Analytics applied can provide valuable
information to various organizations, industries, business, etc. in
the form of prediction, recommendation, decision and the like.
APPLICATIONS OF DATA
ANALYTICS
Finance & Accounting, Business analytics, Fraud , Healthcare,
Information Technology, Insurance, Taxation , Internal Audit,
Digital forensic, Transportation, Food, Delivery, FMCG, Planning
of cities, Expenditure, Risk management, Risk detection, Security,
Travelling, Managing Energy, Internet searching, Digital
advertisement , etc.
REAL LIFE EXAMPLES OF
DATA ANALYTICS
1. Coca-Cola
Coca Cola uses big data analytics to drive customer retention. In the
year 2015, Coca-Cola managed to strengthen its data strategy by building a digital-led loyalty
program. According to a Forbes article, Coca Cola was one of the first globally recognized brands,
outside of the tech sector, to embrace Big Data. In 2015, for example, they were able to determine that
Coca Cola products were mentioned online once every two seconds. Having access to this information
helps them understand who their customers are, where they live, and what prompts them to discuss the
brand.
2. Netflix
Netflix is a good example of a big brand that uses big data analytics
for targeted advertising. With over 100 million subscribers, the company collects huge data, which is
the key to achieving the industry status.If you are a subscriber, you are familiar to how they send you
suggestions of the next movie you should watch. Basically, this is done using your past search and
watch data. This data is used to give them insights on what interests the subscriber most. See the
screenshot below showing how Netflix gathers big data.
3. UOB Bank
UOB bank from Singapore is an example of a brand that uses big data to drive
risk management. Being a financial institution, there is huge potential for incurring losses if risk
management is not well thought of. UOB bank recently tested a risk management system that is based
on big data. The big data risk management system enables the bank to reduce the calculation time of
the value at risk. Initially, it took about 18 hours, but with the risk management system that uses big
data, it only takes a few minutes. Through this initiative, the bank will possibly be able to carry out
real-time risk analysis in the near future.
Amazon leverages big data analytics to move into a large market. The data-
driven logistics gives Amazon the required expertise to enable creation and achievement of greater
value. Focusing on big data analytics, Amazon whole foods is able to understand how customers buy
groceries and how suppliers interact with the grocer. This data gives insights whenever there is need to
implement further changes.
5. Pepsico
A. Microsoft Excel
Basics of Excel
1. Quick Access Toolbar: This is a place where all the important tools
can be placed. When you start Excel for the very first time, it has
only 3 icons (Save, Undo, Redo). But you can add any feature of
Excel to to Quick Access Toolbar so that you can easily access it
from anywhere (hence the name).
For MS office versions 2016 and above Power Query, Power Pivot are by
default installed in Excel. Power query is in Data Tab. Power Pivot add in
needs to be enabled from Developer Tab → Com Add ins. Data Analysis
Tool pack add in can be enabled from Developer Tab →Excel Add ins.
For MS office version 2013 Power Query needs to be installed by
downloading the add in from below link
https://www.microsoft.com/en-in/download/details.aspx?id=39379
BASICS & NAVIGATION
Excel is a software program created by Microsoft that uses spreadsheets to
organize numbers and data with formulas and functions. Excel analysis is
ubiquitous around the world and used by businesses of all sizes to perform
financial analysis.
Excel makes it easy to crunch numbers. With Excel, you can streamline data
entry . Then, get chart recommendations based on your data, and create them
with one click. Or, easily spot trends and patterns with data bars, color
coding, and icons
1. Excel Interface
I. First time when you open MS Excel below is the window you
will see
Open New workbook by clicking on Blank workbook
Recent – Open workbook which you have worked in past
Excel file like size, author, last modified, created on and etc.
Manage Workbook- Recover unsaved workbook as shown in
the image
With Insert feature you can insert cells, rows, columns and sheet.
With Delete feature you can delete cells, rows, columns and
sheet.
With Format feature you can change height of Rows, Autofit row
height, Hide or unhide rows & columns, Organize sheets, and
protection of sheet, lock cell and format cells
Editing – Autosum, Fill, Clear, Sort and filter, Find and
Select
Sort & Filter – Put filter on selected data range, Sorts the data
largest to smallest and vise versa, clears filter.
Tables
Insert slicer – Click on insert slicer to slice and dice the data
according to various categories in data. It works as a filter
(Detailed explanation will be given in Pivot table and slicer
chapter
Page setup & Scale to fit options are used for printing the
document.
Arrange
Bring object forward or send object backward.
VI. Formulas
Functions library – contains various formulas and
functions to be covered in Formula chapter
Defined names – Define cell with name and use them in
formulas.
VII. Data
VIII. Review
Proofing –
Workbook statistics gives details as shown in image
IX. View
Workbook views
Show
X. Developer
Controls –
Help
Community
Page features
Sheet features
Sheet tab Features
FORMULAS & FUNCTIONS
1. Formulas
2. Functions
4. Using AutoSum
1. Financial Formulas
Syntax = NPV(rate,value1,value2…)
Arguments –
Syntax = XNPV(rate,values,dates)
1. Rate = Discount rate for a period
2. Values = Positive or negative cash flows (an array of values)
3. Dates = Specific dates (an array of dates)
Syntax= IRR(values,[guess]
Values - Positive or negative cash flows (an array of values)
Guess - An assumption of what you think IRR should be
Syntax = XIRR(values,dates,guess)
Syntax = SLN(cost,salvage,life)
Cost – cost of asset when bought
Salvage – Value of asset after depreciation
Life – Number of period for which asset is depreciated
2. Logical Formulas
Syntax = AND(logical1,logical2…)
Syntax = FALSE()
Syntax = IF(Logical_test,[value_if_true],[value_if_false])
Syntax = IFERROR(value,value_if_error)
5. IFNA - Returns the value you specify if the expression resolves
to #N/A, otherwise returns the result of the expression
Syntax = IFNA(value,value_if_na)
Syntax = NOT()
Syntax = OR(logical1,logical2..)
Syntax = TRUE()
3. Text Formulas
Syntax = LEFT(text,num_chars)
Syntax = RIGHT(text,num_chars)
Syntax = MID(text,start_num,num_chars)
Syntax = PROPER(text)
5. Upper - Converts text to uppercase
Syntax = UPPER(text)
Syntax = LOWER(text)
Syntax = LEN(text)
Syntax = TRIM(text)
Syntax = SUBSTITUTE(text,old_text,new_text,instance_num)
10. Concatenate – Joins text in various cells
Syntax = CONCATENATE(text,text2…)
Syntax = YEAR(serial_number)
Syntax = MONTH(serial_number)
Syntax = TODAY()
Syntax = NOW()
5. Hour, Minute, Second
Syntax = NETWORKDAYS(start_date,end_date,holidays)
Syntax = EOMONTH(start_date,months)
Syntax = MATCH(lookup_value,lookup_array,match_type)
Syntax = INDEX(array,row_num,column_num)
= INDEX(reference,row_num,column_num,area_num)
Syntax = OFFSET(reference,rows,cols,[height],[width])
4. VLOOKUP - Looks in the first column of an array and moves
across the row to return the value of a cell
Syntax =
VLOOKUP(lookup_value,table_array_index_num,range_lookup)
= range_lookup has 2 options TRUE for approx. match
and FALSE for exact match
Syntax =
HLOOKUP(lookup_value,table_array_index_num,range_lookup)
1. SUM –
Adds all numbers in range of cell
2. Average – Returns average i.e arithmetic mean of arguments
3. COUNT – Counts number of cells in range that contain
numbers
4. COUNTA – Counts number of cell in a range that are not empty
5. COUNTBLANK – Counts number of blank cells
6. ISBLANK – If a cell value is blank it will give output as TRUE
8. SUMIF
Syntax = SUMIF(range,criteria,sum_range)
Syntax = PRODUCT(number1,number2…)
Below is a Report prepared using various formatting tools like chart and
Smart Art.
As shown above we can convert a simple data into a nice and presentable
form with the help of formatting tools available in Excel.
As shown in image below, with this style of formatting and presenting a data
there is no need to rework the data and show it in PowerPoint.
Types of Formatting
Press Ctrl +1 or
1. Numeric
I. Date formatting
II. Special Formatting – Change Security code number formatting and
Phone number formatting.
3. Tools
Justify option allows the text copied from internet or word to be changed.
5. Outlining
After Outline
Grouping
Data Tab – Outline -- Group
6. Visualization
Shape Effects
Themes
Pagelayout – Colours or Themes
7. Conditional
3. Under Choose the data that you want to analyze, select Select a
table or range.
4. In Table/Range, verify the cell range.
5. Under Choose where you want the PivotTable report to be placed,
select New worksheet to place the PivotTable in a new worksheet
or Existing worksheet and then select the location you want the
PivotTable to appear.
6. Select OK.
7. Drag fields
The PivotTable Fields pane appears. To get the total quantity of each
product, drag the following fields to the different areas.
1. Place field to the Rows area.
2. Quantity field to the Values area.
3. Sales Person field to the Filters area.
8. Sort
To get Imphal at the top of the list, sort the pivot table.
Click any cell inside the Sum of Quantity column.
Right click and click on Sort, Sort Largest to Smallest.
Insert Quantity Column 2nd time and perform the step if you want to see
both the Value and Percentage.
In Defer layout update you can select the required fields and then
update
This feature is used for huge data which takes time for updating.
15. Filter
Because we added the Sales Person field to the Filters area, we can
filter this pivot table by Sales Person.
1. Click the filter drop-down and select any sales person.
16. Design Tab
Right click on the slicer and click on Report connections and choose
the pivots you want to control with slicers.
3. Design Tab for Slicers
In Buttons and size field change the number of columns, heights, width
of buttons and size of slicer in size feature. Arrange the slicers in
arrange feature. Change styles of slicer and also you can create new
styles for slicer
4. Slicer settings
Click on slicer setting in Design tab the below dialogue box will open
Change name , Sort , Hide items with no data, Show items with no data
are some settings which can be done.
Select any field to filter the data and click on clear filter to remove
selection.
With multi select feature besides filter icon you can select multiple
fields or you can use Press Ctrl and then select with mouse.
POWER QUERY
What is Power Query
Power Query is a data transformation and data preparation engine. Power
Query comes with a graphical interface for getting data from sources and a
Power Query Editor for applying transformations. Because the engine is
available in many products and services, the destination where the data will
be stored depends on where Power Query was used. Using Power Query, you
can perform the extract, transform, and load (ETL) processing of data.
How Power Query helps with data acquisition
Business users spend most of their time on data preparation, which delays the
work of analysis and decision-making. Several challenges contribute to this
situation, and Power Query helps address many of them.
Existing challenge How does Power Query help?
Finding and connecting to data is Power Query enables connectivity to
too difficult a wide range of data sources,
including data of all sizes and shapes
Experiences for data connectivity Consistency of experience, and parity
are too fragmented of query capabilities over all data
sources
Data often needs to be reshaped Highly interactive and intuitive
before consumption experience for rapidly and iteratively
building queries over any data
source, of any size
Any shaping is one-off and not When using Power Query to access
repeatable and transform data, you define a
repeatable process (query) that can
be easily refreshed in the future to
get up-to-date data.
In the event that you need to modify
the process or query to account for
underlying data or schema changes,
you can use the same interactive and
intuitive experience you used when
you initially defined the query.
Volume (data sizes), velocity (rate Power Query offers the ability to
of change), and variety (breadth of work against a subset of the entire
data sources and data shapes) dataset to define the required data
transformations, allowing you to
easily filter down and transform your
data to a manageable size.
Power Query queries can be
refreshed manually or by taking
advantage of scheduled refresh
capabilities in specific products (such
as Power BI) or even
programmatically (by using the Excel
object model).
Because Power Query provides
connectivity to hundreds of data
sources and over 350 different types
of data transformations for each of
these sources, you can work with
data from any source and in any
shape.
Power Query experiences
The Power Query user experience is provided through the Power Query
Editor user interface. The goal of this interface is to help you apply the
transformations you need simply by interacting with a user-friendly set of
ribbons, menus, buttons, and other interactive components.
The Power Query Editor is the primary data preparation experience, where
you can connect to a wide range of data sources and apply hundreds of
different data transformations by previewing data and selecting
transformations from the UI. These data transformation capabilities are
common across all data sources, whatever the underlying data source
limitations.
When you create a new transformation step by interacting with the
components of the Power Query interface, Power Query automatically creates
the M code required to do the transformation so you don't need to write any
code.
Transformations
The transformation engine in Power Query includes many prebuilt
transformation functions that can be used through the graphical interface of
the Power Query Editor. These transformations can be as simple as removing
a column or filtering rows, or as common as using the first row as a table
header. There are also advanced transformation options such as merge,
append, group by, pivot, and unpivot.
All these transformations are made possible by choosing the transformation
option in the menu, and then applying the options required for that
transformation. The following illustration shows a few of the transformations
available in Power Query Editor.
After clicking on From Table Power Query Editor will open as shown in
Image
In Power Query Editor you can clean and transform the data.
After Importing Sales Data. Go to Home tab in Power query Editor and click
on Close and Load To
Load to window will appear. Click on Only create connection and click on
Load.
Now Import Location Master from master sheet in assignment file into power
query
Reference Query creates a Copy of the Query with previous steps stored in
Sales Data.
Whatever steps performed in original query are reflected in Reference query.
Change the name of the query as “Sales Analysis”
Next we will merge Location data with Sales data and insert new column of
Location with the help of common column “State”. Click on Merge Queries
in Home tab → Merge Queries.
A merge window will appear. Select “State” column from Sales Analysis in
1st table. In 2nd table select Location data → Select “State” column. In Join
Kind select “Left Outer” and Click OK.
A new column gets inserted name “Location”. Click on the double arrows to
expand the column.
Select “Location” and untick on “Use Original Column name prefix”. Click
Ok . “Location” Column will be inserted.
Next Step Change the type of Bill Date column and convert it to “Date”
format.
There are 2
ways to change the Format type.
1) In Home tab → click on Data Type → change the format from
selection
2) Top left corner of Column click on the icon and change the format
type.
Insert Year Column – Select the Bill Date column. Go to Add Column Tab
→ Column from examples → From Selection
A New column will be inserted. Type “Year” select the year. Press Enter and
Click OK
Same way Insert Month Column. Select Bill Date Column again, Go to Add
column select column from examples then Frpm selection. In New Column
Type “Month” press enter and click Ok
Insert Day column following above steps.
Insert Profit Ratio Column. Go to Add column tab. Select Custom column.
A Custom column window appears. Type Profit Ratio in New Column Name.
In Custom column formula Select the Column heading “Profit” press “/” and
select “Sales Value” click on “Ok”. Same way Insert Cost Ratio
Change type to Percentage
Now Group By the Columns. Select the Sales Person Name and click on
Group by. Group By feature summarizes the data.
In Group by Select “Advanced”. One part Select only Text columns. In 2nd
part select number and value columns. In Operation select “Sum” Select
Column Quantity, Sales Value and Profit and click OK. To add more column
click on Add aggregation.
Workbook Queries Tab. This tab stores All the Queries created in the Excel
file. You can anytime Edit queries as required by double clicking on any
query or Right click and edit.
Right click on the query . You will get various options to edit queries.
Importing Excel file from a “Folder”
Save the data shared of Sales Data – CY and PY in a folder and name it as
Sales.
Open a blank Excel workbook and Save it as Sales Analysis Report.
Click on Data Tab → New Query → From File → From Folder
Next a new dialog box will appear as shown in image. Click on Browse and
select the folder you want to import. Import the “CY” Folder. After locating
the folder click on “CY” and Click on Open.
Click on OK and let it load.
A new window will pop up. Click on Combine and Load To
In Combine files window Select the relevant sheet. In current file select
“Sheet1” and click “OK”
Click on “Only create connection”
Similarly Select Bill Date column. Go to Add Column tab and click on
Column from Examples → Select from selection. A new column will appear.
Type Month in the cell and select the “Month”. In current scenario select
“Month”. Press Enter and click “OK”
Reorder Columns
Reorder columns and change the location where you want to place it. Select
number of columns required for more than one → Press Ctrl and select
columns → Right click → Move → select out of 4 options available. Another
way to move is by selecting the column press left click and drag to location
as required.
Remove Other Columns and Pivot
Right Click on Sales Data and click on Reference. Rename the New query as
“Placewisesales”
A Pivot window will pop up from drop down select “Taxable Value” and
click on “OK”
The Result of Pivot column is shown in image. First the years were in rows
now after pivot the two years are shown in columns.
Transpose
Select the both the columns. Go to Transform Tab → Transpose.
Promote Headers
Go to Home tab → Select Use first row as Headers → select use first row as
headers.
Change Type
Select all the columns. Go to Home Tab → Data Type → Select Decimal
Numbers.
Split Column
Right Click on Sales Data and click on Reference. Rename the New query as
“SplitColumn”
Go to Home Tab → Choose columns → Select Choose columns → Select
Column heads Bill Date.
Select Bill Date and change type to Text.
Select Bill Date column and Right click and select “Split Column” and select
by Dilimiter.
After selecting by Dilimiter a window will pop up. From drop down select
custom then below
Put “ – “. In Split by select each occurrence of the delimiter.
Replace Values
Right Click on Sales Data and click on Reference. Rename the New query as
“Replace Values”
Select Unit column and Replace value window will pop up.
In Values to Find type “Nos” and in Replace with type “Units” and press OK.
Rename Column
Right Click on Sales Data and click on Reference. Rename the New query as
“Rename column”
Go to Home Tab → Choose columns → Select Choose columns → Select
Column heads Category, Description of goods and Taxable value. Double
click on the column name and change the name of Taxable Value to “Sales”
Select all the data with Ctrl + A and Transpose the data from Transform tab
→ Transpose
If any errors in any column. Select the column → Right Click → Replace
Errors
A new window will pop up. Give required value. If Number column then
number value. If Text then text value
If still Error remains then go to home tab → Remove Rows → Remove
Errors
Select data type detection currently Based on first 200 rows is selected.
Copy the link and paste in the URL box and click Ok
A Web connector window will pop up. Select Anonymous and Click Ok
The available authentication methods for this connector are:
Anonymous: Select this authentication method if the web page doesn't
require any credentials.
Windows: Select this authentication method if the web page requires your
Windows credentials.
Basic: Select this authentication method if the web page requires a basic user
name and password.
Organizational account: Select this authentication method if the web page
requires organizational account credentials.
Select the States of the United states of America table and select Load to
table.
Similarly Import Stock Market Data from Below link and follow same steps
as given above and select “Table 0” and Load to table.
https://www.moneycontrol.com/stocks/marketinfo/marketcap.php?
optex=BSE
Steps to Automate Sales Analysis Report with Excel Database.
(Note to change the data source of base data check steps on last page of
this note)
Data Given
1. Month Wise sales data 2020 & 2019 (Apr, May, Jun, July, Aug).
Two folders PY and CY.
2. Master
a. OverheadRatio
b. SP_Commission (Sales Person Commission)
c. Tax
Steps
1. Import Month wise sales data and append in one table in power
query
2. Import Masters and merge with the appended table
In Combine window select Combine → Combine and load to. A new window
will pop up → Select “only create connection” and untick on others and click
“OK”.
Similarly import “PY” data and import it to power query.
Import Master tables
Go to Data tab → New Query → From file → From workbook
The Data imported is stored in power query and can be seen in Workbook
queries as shown in the image
Create folders in workbook queries pane and organize the queries for better
navigation and identification of Data.
Right click on “CY” → Move to Group →New Group→ Name it as Raw
Data .
Move the PY query to Raw Data folder
Right click on the “PY” → Move to Group → Raw Data.
In Merge window Select Overhead Ratio table and select Category in both
the data and click on OK
SP Commission
In Merge window Select SP commission table and select Sales Person Name
in both the data and click on OK
Taxes Column
Go to Add Column tab → Select Custom Column
Name it as Taxes and in formula window select Tax.1 then press “ * ” and
then select Taxable value and click ok
Commission Column
We want commission in 0.2 format hence select the Commission column and
go to Transform Tab → Select Standard → Select Divide and divide it by
100.
Profit Column
Go to Add Column tab → Select Custom Column
Name it as Profit and in formula window select Taxable value then press
minus and then select Cost press minus select OH Cost press minus select
Taxes press minus select commissionofSP and click ok
Insert Year Month name and Week Columns
Year
Select Bill Data column and Go to Add column → Column from examples →
from selection
In new column type Year select 2020 and press enter and click on OK
Month Name
Select Bill Data column and Go to Add column → Column from examples →
from selection
In new column type Month select Month and press enter and click on OK
Week
Select Bill Data column and Go to Add column → Column from examples →
from selection
In new column type Week select week and press enter and click on OK
Change type
Select OH cost , Taxes, CommissionofSP & Profit and change the type to
decimal numbers. Go to Home tab → Data type → Decimal Numbers
Go to Home Tab → Close and Load to → Load to Table.
You will get Sales person Name who’s name is not there in the Commission
master and which needs to be updated. In current scenario Varun and
Durgesh name is not present in master and there commission needs to be
updated.
Change the Source of the Base data in below window. Select 1st link ends
with CY → Click on Change source
Click on Browse and locate the folder where the data is stored
Select the CY folder and click on Open
Similarly perform similar steps for “PY” and “Master” and then click on
Close.
POWER PIVOT
Power Pivot
Power Pivot is a Powerful data analysis and data modeling tool in Excel.
Power Pivot is an Excel add-in you can use to perform powerful data analysis
and create sophisticated data models. With Power Pivot, you can mash up
large volumes of data from various sources, perform information analysis
rapidly, and share insights easily.
In both Excel and in Power Pivot, you can create a Data Model, a collection
of tables with relationships. The data model you see in a workbook in Excel
is the same data model you see in the Power Pivot window. Any data you
import into Excel is available in Power Pivot, and vise versa.
How the data is stored
The data that you work on in Excel and in the Power Pivot window is stored
in an analytical database inside the Excel workbook, and a powerful local
engine loads, queries, and updates the data in that database. Because the data
is in Excel, it is immediately available to PivotTables, PivotCharts, Power
View, and other features in Excel that you use to aggregate and interact with
data. All data presentation and interactivity are provided by Excel; and the
data and Excel presentation objects are contained within the same workbook
file. Power Pivot supports files up to 2GB in size and enables you to work
with up to 4GB of data in memory.
Saving to SharePoint
Workbooks that you modify with Power Pivot can be shared with others in all
of the ways that you share other files. You get more benefits, though, by
publishing your workbook to a SharePoint environment that has Excel
Services enabled. On the SharePoint server, Excel Services processes and
renders the data in a browser window where others can analyze the data.
On SharePoint, you can add Power Pivot for SharePoint to get additional
collaboration and document management support, including Power Pivot
Gallery, Power Pivot management dashboard in Central Administration,
scheduled data refresh, and the ability to use a published workbook as an
external data source from its location in SharePoint.
Power Pivot Installation
For All Pro versions MS Excel 2013 and above Go to Developer Tab → Com
Add-ins→Select Microsoft Power Pivot for Excel → Click Ok → Power
Pivot Tab is enabled as shown in Image.
From the Power Pivot ribbon tab, select Manage from the Data Model
section.
When you select Manage, the Power Pivot window appears, which is where
you can view and manage the data model, add calculations, establish
relationships, and see elements of your Power Pivot data model. A data
model is a collection of tables or other data, often with established
relationships among them. The following image shows the Power Pivot
window with a table displayed.
The Power Pivot window can also establish, and graphically represent,
relationships between the data included in the model. By selecting the
Diagram view icon from the bottom right side of the Power Pivot window,
you can see the existing relationships in the Power Pivot data model. The
following image shows the Power Pivot window in Diagram view.
Similarly write “Sum” formula for Cost, OHCost, Tax Value, Commission
Value
Formula for Cost → Costs:=SUM(SalesCYPYData[Cost])
Formula for OHCost → OHCost:=SUM(SalesCYPYData[OH Cost])
Formula for Tax Value → Tax Value:=SUM(SalesCYPYData[Taxes])
Formuma for Commission Value → Commission
Value:=SUM(SalesCYPYData[ComissionofSP])
Derive Profit by deducting Costs from Sales Value
Profit Value:=[Sale]-[Costs]-[OHCost]-[Tax Value]-[Commission Value]
Profit Ratio
Profit Ratio:=[Profit Value]/[Sale]
Select the SalesCYPYdata table. In that click on category column and right click and select create
Hierarchy.
Name it as C2d.
Click on Diagram view Go to SalesCYPYData table and create hierarchy of Timeseries by Adding
Total, Year, Month, Week, Billdate
Working with multiple tables makes data more interesting and relevant to the
PivotTables and reports that use that data. When you work with your data
using the Power Pivot add-in, you can use Diagram View to create and
manage the connections among the tables you imported. Creating table
relationships requires that each table has a column that contains matching
values.
Two separate data sets with a common column can be controlled and merged
into one pivot with the help of Relationship feature.
In current example Sales Data is at detailed level, whereas Fixed cost is
available at Category level.
Import 3 Masters from New Master Filles – Fixed Cost, Date Table,
Electricity
Go to Data → New Query → From File → from workbook → New Master.
Select Multiple Items and select the three tables and click on create only
connection and select “Add this data to data model” and click ok
Go to Power Pivot window click on Diagram view. There are total 4 tables.
Create a relationship with sales data and the three masters
Fixed Cost
Select Category in Sales Data → Left click and drag the mouse to Category
in fixed cost and leave the mouse. Relationship is created
Date Table
Select Start of the Month in Sales Data → Left click and drag the mouse to
Date in DateTable and leave the mouse. Relationship is created
Electricity
Select Start of the Month in Sales Data → Left click and drag the mouse to
Date in Electricity and leave the mouse. Relationship is created
Close the Power Pivot Window. Go to Insert Tab and Insert Pivot table in a
New worksheet OR from home tab insert Pivot Table.
In Pivot table fields From Fixed costs table select Category in Rows, Select
Fixed Costs in Values, From SalesCYPYdata Select Costs and Total Costs in
Values.
As seen in the image the pivot is prepared from two Tables SalesCYPYData
and Fixed Cost
Calculate Function
Syntax = CALCULATE( <expression>, <filter1>, <filter2>… )
The expression that we put in the first parameter has to be evaluated to return
the result (that is a value, not a table). For this reason, the expression is
usually an aggregation function like SUM, MIN, MAX, COUNTROWS and
so on.
This expression is evaluated in a context that is modified by the filters in the
following parameters. A key point is that these filters can both enlarge and
restrict the current context of evaluation.
Calculate with ALL function
ALL Function avoids all the filter selection of slicers.
Insert a measure of ALL as shown below. Select expression as sales and filter
as ALL and in ALL select Category Column.
All:=CALCULATE([Sale],ALL(SalesCYPYData[Category]))
With the above measure the Sales total will remain same in the pivot with no
effect of slicer filters
Close the power pivot window and Go to inset tab and insert a Pivot. Select
Party Name, ALL, Sale and insert a slicer for Category and select any
category. As you can see in the image the ALL column has not changed and
its showing total whereas the sales is showing the filter selection of Furniture.
Syntax --
Stationery:=CALCULATE([Sale],FILTER(SalesCYPYData,SalesCYPYData[Category]=
In Calculate select Sale as expression and in filter insert Filter function and
select the sales table and Category column and then type “=” and type
“Stationery” and close the bracket.
Similarly insert measure for other categories.
From the above measures we will get filtered data for all categories.
The Same measures can be used in Pivots.
Filter functions filters the data according to the criteria given. It’s the same
concept as we select a category from a filter. Filter function does the same
function
CHARTS & DASHBOARD
Charts
It is a visual representation of data from a worksheet that can bring more
understanding to the data than just looking at the numbers. A chart is a
powerful tool that allows you to visually display data in a variety of different
chart formats such as Bar, Column, Pie, Line, Area, Doughnut, Scatter,
Surface, or Radar charts. With Excel, it is easy to create a chart.
Continuing with our previous practice files, we will create interactive charts
from the data to make it more presentable and to get more insights.
Charts can be created from a structured data with proper heading and data
supporting the same. We will create “Pivots” as our base data for charts.
Insert a sheet in Sales Analysis Report and name it as Pivot for Charts.
Timeseries sales Chart
Insert a Pivot and select Timeseries hierarchy in rows and Sales in values.
Name the Chart in Analyze tab → Under Pivot table names as
TimeseriesSales. And put a same heading above the pivot.
Now select the pivot and insert a bar chart.
There are 2 ways to insert a chart
1. Press Alt+F1
2. Inert Tab → Charts section
Right click on the chart and save it as Template so that we can use the same
template for other charts.
Select “C2d” hierarchy in rows and Sales in Values. Name the Pivot as
Cat2GoodsSales. And give same as title.
Insert Chart in similar manner as above. Select the chart and Change the chart
type from design tab
Change the title of the chart Category to Goods Sales and change the
formatting and colour.
Category Pie Chart
Insert a pivot and select “Category” in rows and “Sales” in values. Name the
pivot in Analyze tab as “CategoryPiechart”.
Insert 2D Pie chart from Insert Tab under Chart section.
Click on the Plus sign and under Data labels select Data callout and then
select outside End
Right Click on the Chart and Select “Format Chart Area”. Select the Pie → in
Format data series pane under the Bar icon → Series options → Change the
angle of first slice and increase the pie explosion as required.
Create Total Cost Measure in Power Pivot
Go to Power Pivot tab and click on Manage → SalesCYPYdata enter the
below dax measure
Total Costs:=[Costs]+[OHCost]+[Tax Value]+[Commission Value]
Category Wise Profit Chart
Insert Pivot and Add Category in Rows, Sales, Total Cost and Profit Value in
Values
Insert Bar chart from Insert Tab and change the chart type from design tab
and select Template saved.
Sales Person wise Chart
Insert Pivot and select Sales person Name in Rows and Sales in Values and
name the pivot as salespersonwisesales
Insert Bar Chart and change the chart type from design tab and
select Template. Give it title.
Create a new sheet and name it as “ Sales Analysis” and move all the Charts
to this sheet.
Dashboard
Let’s Create an interactive Dashboard by adding Slicers
Click on any of the chart and go to Insert tab and click on slicers
Select Year, Month, Week, Party Name, Category, Place, Sales Person name.
Right click on the slicers and click on Report connection and connect all the
slicers with All the charts except the Category PIE chart.
Now the naming of Pivot tables will help you to select the pivots to connect
with slicers.
Interactive Dashboard
When new data is updated in respective files save it and open the Sales
analysis Report go to Data tab and click on Refresh All.
Power query will update the data at back end and Power pivot data will also
get updated.
Similarly all charts and slicers will get updated.
Select the data source one at a time click on change source and change the
Path and browse it to required path and click ok. Repeat for all the sources
and then click on close.
PRACTICE FILES LINK
https://drive.google.com/drive/folders/10WsD3ETg4vqFxOMFy11iRIB4nce5Ar5j?
usp=sharing
ABOUT THE AUTHOR
Punit Prabhu
Experienced Business Consultant specializing with more than 10 years of
experience in Data Analytics, Data mining, Digital Forensic and Cost
Analysis, Cost control, Cost reduction . MS Excel & Power BI enthusiast and
address Excel related queries through WhatsApp, my blog and YouTube
channel at a National and International Level. I have catered to a diverse
clientele across industries.