You are on page 1of 77

Business Analytics

Today Objective

warehouse simulation (advance Features)…..

Indian Institute of Management (IIM),Rohtak


Summery of last session

Indian Institute of Management (IIM),Rohtak


Case (store.xlxs)

Q1.Calculate Total Prices Store wise and also


calculate the percentage of sales at each store?
Q2. Summarizing prices by month with store ?
Q3. Calculate total Prices of each product ?
Q4. identify products names which contains 80%
values
Q5. Summarizing prices by month(Feb, July and
December) with store wise for products (Adhesive1,
Adhesive4, Adhesive9,Saftey5,Saftey8 and Tape4) ?
Q6. Find out store wise total in each of the month
for the product (Saftey1---10 and Tape1…..10)only.

Indian Institute of Management (IIM),Rohtak


Data Model

Indian Institute of Management (IIM),Rohtak


Data Model

A Data Model is an approach for


integrating data from multiple tables,
effectively building a relational data
source inside an Excel workbook.
Within Excel, Data Models are used
transparently, providing tabular data
used in PivotTables, PivotCharts, and
Power View reports.
Indian Institute of Management (IIM),Rohtak
Data Model
How can I add data to data model
Before adding any data to the data model, you
should make the data in a proper table
structure.(column header etc.)
{Datmodeltemp.xlsx}
In the Reps.xlsx worksheet formulate tabular
structure ,same with Sales.xlsx (also sure array
name must be Reps & Sales )
Step: Select table ,then Crt+T ,formula ,then
name manger ,edit (for write array name) repeat
this step for both tables Indian Institute of Management (IIM),Rohtak
Data Model
How can I add data to data model
Press Ctrl+T

Indian Institute of Management (IIM),Rohtak


Data Model
How can I add data to data model

Repeat this information for Second Sheet

Indian Institute of Management (IIM),Rohtak


Data Model
How can I create relationship with data model

If you want to summarize sales by state, you


have a problem ,At present ,there is no way
for excel to know each salesperson’s state.
Somehow you need to create a relationship
that Enables excel to determine the state for
each row of data in the Sales table.
Now click data tab ,then Relationship,
selecting New opens the create Relationship
dialog box
Indian Institute of Management (IIM),Rohtak
Data Model

Indian Institute of Management (IIM),Rohtak


Data Model
Now Select Pivot table from insert tab

Indian Institute of Management (IIM),Rohtak


Data Model

Indian Institute of Management (IIM),Rohtak


Data Model

Indian Institute of Management (IIM),Rohtak


Data Model
If you click the total sales for any state (Alaska here) you see the quick
explore icon shown in below figure .Clicking the drop down arrow to
the right of the icon opens the box . Click drill to ID.

Indian Institute of Management (IIM),Rohtak


Data Model
How can I remove data from data model
To remove data from data model ,click data tab on the ribbon and then
select Connections.

Indian Institute of Management (IIM),Rohtak


Data Model
Case
The Faberu.xlsx file contains salaries, travel
expenses, Faculty ID, Department code, and Faculty
code for all business school faculty. Use this data to
answer the following questions.
1. Use the data model to create a pivot table that
gives average salary broken down by department
2. Use the data model to create a pivot table that
gives average salary broken down by type of
faculty member and department
3. Use the data model to create a pivot table that
gives average travel expenses by department
Indian Institute of Management (IIM),Rohtak
Data Model

Indian Institute of Management (IIM),Rohtak


Data Model

Indian Institute of Management (IIM),Rohtak


Data Model
Then data tab and click relationship, then new

Indian Institute of Management (IIM),Rohtak


Data Model

Indian Institute of Management (IIM),Rohtak


Data Model

Indian Institute of Management (IIM),Rohtak


Data Model
Insert tab click pivot table

Indian Institute of Management (IIM),Rohtak


Data Model

Indian Institute of Management (IIM),Rohtak


Data Model
1. Use the data model to create a pivot table that gives average
salary broken down by department

Indian Institute of Management (IIM),Rohtak


Data Model
2.Use the data model to
create a pivot table that
gives average salary
broken down by type of
faculty member and
department Indian Institute of Management (IIM),Rohtak
Data Model

Indian Institute of Management (IIM),Rohtak


Data Model

3.Use the data model to


create a pivot table that
gives average travel
expenses by department

Indian Institute of Management (IIM),Rohtak


Data Model

Indian Institute of Management (IIM),Rohtak


Data Model

Agility with Power Pivot


CASE

Indian Institute of Management (IIM),Rohtak


Power Pivot
PowerPivot for Excel also includes a wizard that
you can use to import data from different
sources, ranging from large corporate
databases on your intranet, to public
data feeds, to spreadsheets and text files on
your computer. Data is imported into
PowerPivot for Excel as tables. These tables are
shown as separate sheets in the PowerPivot
window, similar to worksheets in an Excel
workbook. But PowerPivot for Excel provides
significantly different functionality from what is
available in an Excel worksheet.
Indian Institute of Management (IIM),Rohtak
Power Pivot
Power Pivot is an add-in you can use to perform powerful
data analysis in Excel. The add-in is built into certain
versions of Excel, but by default, it's not enabled. Here’s
how you enable Power Pivot before using it for the first
time.
1.Go to File > Options > Add-Ins.
2.In the Manage box, click COM Add-ins> Go.
3.Check the Microsoft Office Power Pivot box, and then
click OK. If you have other versions of the Power Pivot
add-in installed, those versions are also listed in the COM
Add-ins list. Be sure to select the Power Pivot add-in for
Excel.
Indian Institute of Management (IIM),Rohtak
Power Pivot
How can I load data in to pivot table

Indian Institute of Management (IIM),Rohtak


Power Pivot
Power pivot tab then click mange (for external data)

Indian Institute of Management (IIM),Rohtak


Power Pivot
To illustrate how to download data from
multiple sources into Power pivot ,use the
Storesales.txt text file, in which is listed Sales
transactions from 20 stores.

You Can see that each transaction, you are


given to store number, the product sold, sales
date, unit solds,and revenue. You want to
summarize this date by state, but the state for
each store is listed in a different file
,State.xlsx.
Indian Institute of Management (IIM),Rohtak
Power Pivot
You want to create pivot table that enables you to slice and dice your
data so that you can view how you performed selling each product in
each state. To begin ,click the PowerPivot tab and then click mange to
open power pivot window.(click external data)

Indian Institute of Management (IIM),Rohtak


Power Pivot

Indian Institute of Management (IIM),Rohtak


Power Pivot

Indian Institute of Management (IIM),Rohtak


Power Pivot

Indian Institute of Management (IIM),Rohtak


Power Pivot
Now close button

Indian Institute of Management (IIM),Rohtak


Power Pivot
Next, you want to import the States.xlsx file so that you can
relate to sales data. To import States.xlsx ,return to excel by
clicking the switch to workbook excel icon in the upper left
corner.

Process will repeat for States.xlsx


Again click get external data ,and choose excel sheet tab
Indian Institute of Management (IIM),Rohtak
Power Pivot

Indian Institute of Management (IIM),Rohtak


Power Pivot

Indian Institute of Management (IIM),Rohtak


Power Pivot

Click diagram view

Indian Institute of Management (IIM),Rohtak


Power Pivot

Indian Institute of Management (IIM),Rohtak


Power Pivot
Now creating pivot table and analysis
Now click the pivot table in your sheet where
you made your diagram

Indian Institute of Management (IIM),Rohtak


Power Pivot

Indian Institute of Management (IIM),Rohtak


Power Pivot
Analysis : summarize the revenue ,unit sold with states and
products

Indian Institute of Management (IIM),Rohtak


Power Pivot
Slicers with pivot table

Indian Institute of Management (IIM),Rohtak


Power Pivot
Slicers with pivot table

Indian Institute of Management (IIM),Rohtak


Power Pivot

Indian Institute of Management (IIM),Rohtak


Power Pivot
Based upon discussion :
Summarize total revenue by store (1,10,15) and create a slicer
for stores

Indian Institute of Management (IIM),Rohtak


Power Pivot

Indian Institute of Management (IIM),Rohtak


Pivot Table In R

Indian Institute of Management (IIM),Rohtak


Rstudio screenshot

Indian Institute of Management (IIM),Rohtak


Workspace and Working Directory
> getwd():It shows the working directory

Indian Institute of Management (IIM),Rohtak


Creating Vectors
A vector is a sequence of data elements of the same basic type.
We create a vector in R using “c” or “concatenate command”

Indian Institute of Management (IIM),Rohtak


Pivot Table
Load the devtools library in R
The aim of devtools is to make package
development easier by providing R functions that
simplify common tasks.

Indian Institute of Management (IIM),Rohtak


Pivot Table
Load the devtools library in R

The aim of devtools is to make package


development easier by providing R functions that
simplify common tasks.
Install devtools
Install rpivotTable

Indian Institute of Management (IIM),Rohtak


Pivot Table

to install a package from github you need


to have devtools package already
installed and then use the command
below run: options(download.file.metho
d = "wininet")
library(devtools)
library(rpivotTable)
install_github("ramnathv/htmlwidgets")
install_github("smartinsightsfromdata/rpiv
otTable")
Indian Institute of Management (IIM),Rohtak
Pivot Table

Indian Institute of Management (IIM),Rohtak


Pivot Table
Load the ?rpivotTable

Indian Institute of Management (IIM),Rohtak


Pivot Table

Load the both csv file

Store both csv files in this location (as


mentioned in your device )
I am going to put both files in my
Documents folder
Indian Institute of Management (IIM),Rohtak
Import Data (input.csv)

 data <- read.csv("C:/Users/admin/Desktop/input.csv")

• data <- read.csv("input.csv")

data <- read.csv(file.choose(), header=T)

Indian Institute of Management (IIM),Rohtak


Excel file
library("readxl")
my_data <-
read_excel("my_file.xls")
my_data <- read_excel(file.choose())
# Specify sheet by its name
my_data <- read_excel("my_file.xlsx", sheet =
"data")
# Specify sheet by its index
my_data <- read_excel("my_file.xlsx", sheet = 2)
Indian Institute of Management (IIM),Rohtak
Import from Desktop
The function read.table() can then be used to read the data frame
directly

> airqual <- read.table("C:/Desktop/airquality.txt")

Similarly, to read .csv files the read.csv() function can be used to read
in the data frame directly

> airqual <- read.csv("C:/Desktop/airquality.csv")

excle:
library("readxl")
airqual <-
read_excel("C:\\Users\\admin\\Desktop\\BA_Gradesheet.xl
sx") Indian Institute of Management (IIM),Rohtak
Pivot Table

espn = read.csv("espn.CSV",header=TRUE)

or espn = read.csv("espn.CSV")

rpivotTable(espn)

Indian Institute of Management (IIM),Rohtak


Pivot Table
>library(rpivotTable)
espn = read.csv("espn.CSV",header=TRUE)
rpivotTable (objectname, rows=“ ",col=“ ",aggregatorName=“ ",
vals=“`", rendererName="Table")

rpivotTable(espn, rows="Gender",
col="Location",
aggregatorName="Average",
vals="Income",
rendererName="Table")
Indian Institute of Management (IIM),Rohtak
Pivot Table

Indian Institute of Management (IIM),Rohtak


Pivot Table
>library(rpivotTable)
espn = read.csv("espn.CSV",header=TRUE)
rpivotTable(espn, rows="Gender", col="Location",
aggregatorName=“count", vals="Income",
rendererName="Table")

Indian Institute of Management (IIM),Rohtak


SOURCE CODE FOR INTERACTIVE
PIVOT CHART

Indian Institute of Management (IIM),Rohtak


Pivot Table

Indian Institute of Management (IIM),Rohtak


Pivot Table

Another example of the data sheet Pivot-table.CSV

library(rpivotTable)
Product = read.csv("pivot-
table.CSV",header=TRUE)
rpivotTable(Product, rows="Product",
col="Catgeory",
aggregatorName="Average",vals="A
mount", rendererName="Table")
Indian Institute of Management (IIM),Rohtak
Pivot Table

Indian Institute of Management (IIM),Rohtak


Pivot Table

THE INTERACTIVE MENU FOR PIVOTTING

Indian Institute of Management (IIM),Rohtak


Pivot Table

Case :espn.csv
Q1.Analyzing the gender of subscribers in
terms of percentage?

library(rpivotTable)
Library(devtools)
espn = read.csv("espn.CSV")
rpivotTable(espn, row="Gender")

Indian Institute of Management (IIM),Rohtak


Pivot Table

Indian Institute of Management (IIM),Rohtak


Thank you !!!
Indian Institute of Management (IIM),Rohtak

You might also like