6433 Bi

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 131

Hindi Vidya Prachar Samiti’s

Ramniranjan Jhunjhunwala College of Arts, Science


& Commerce
(Empowered Autonomous College)

Affiliated to
UNIVERSITY OF MUMBAI

DEPARTMENT OF INFORMATION TECHNOLOGY


2023-2024

t.Y.B.Sc. (IT) SEM VI

PAPER rjsUITp603 – business intelligence

Name : Khan Ariba Mohammed Hakim


Roll No. : 6433
Hindi Vidya Prachar Samiti’s
Ramniranjan Jhunjhunwala College of Arts,
Science & Commerce
(Empowered Autonomous College)

Affiliated to
UNIVERSITY OF MUMBAI

This is to certify that Ms. Khan Ariba Mohammed Hakim , Roll No.
6433 of TY BSc IT class has completed the required number of
Experiment of Practical business intelligence, in partial
fulfilment of the Requirements for the award of the degree of
Bachelor of Science (Information Technology) during the academic
year 2023-2024.

College seal Sign of Co-Ordinator


INDEX
Sr. No. Title Date Remark

1 Data Analysis using Excel 07/12/23

2 What-if Analysis using Excel and Power BI 14/12/23

3 Creating Pivot Table and Pivot Chart using Excel and Power BI 04/01/24

4 Import data from legacy data structures. 11/01/24

5 ETL and Data Modeling in Power BI 18/01/24

6 Creating Reports and Charts in Power BI 25/01/24

7 Creating Dashboards in Power BI 08/02/24

8 DAX Queries in Power BI 23/02/24

9 Implementation of Regression Algorithms using Python 30/01/24

10 Implementation of Classification Algorithms using Python 23/02/24

11 Implementation of Clustering Algorithms using Python 23/02/24


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Practical No : 1

Data Analysis using Excel

Demonstrate the use of various features of Excel that are required to do the data analysis.
Example: Result Analysis

Open Excel

Select a blank sheet

Ramniranjan Jhunjhunwala College 1


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Enter the below data:

FORMULAE:
Formula to calculate values of Total = SUM(C3:F3)
Formula to calculate values of Percentage = G3/400*100
Formula to calculate values of Rounded % = ROUNDUP(H3,0)

Duplicate Values : The cells will be highlighted having duplicate values.


Select the cells of the Name column .Select the Duplicate Value from Highlighted Cells Rules of Conditional
Formatting from the Home tab. Select the colour

The result will be

Ramniranjan Jhunjhunwala College 2


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Less Than… : The cells with less values will be highlighted.


Select values of Sub1 Marks. Select Less Than…. from the Highlighted Cells Rules of Home tab.

Set the range and select the colour

The result will be

Ramniranjan Jhunjhunwala College 3


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Similar for Sub2 Marks, Sub3 Marks and Sub4 Marks

Data Bars : This will add the coloured data bar to represent the value.
Select the values of the Total column. Select Data Bars of Conditional Formatting from Home tab. Select
colour

The result will be

Ramniranjan Jhunjhunwala College 4


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Top/Bottom Rules : The highest or the lowest value(s) will be highlighted.


Select the values of the Percentage column.
Select the Top 10 items…. of Top/Bottom Rules from the Home tab then select colour.

The result will be

Icon Sets : Set of icons to represent the values.


Select the set of icons of your choice from the Icon Sets of Home tab.

Ramniranjan Jhunjhunwala College 5


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

The result will be

Stacked Bar Chart : This chart is used to compare the values.


Select the values of the Total column. Select the Stacked Column of Charts from the Insert tab.

Ramniranjan Jhunjhunwala College 6


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Do the formatting and the result will be

Similarly for the Percentage column, but select Pie chart instead of Stacked Bar. The result will be

Select the values from Sub1 Marks to Sub2 Marks to represent it in Line Chart

Ramniranjan Jhunjhunwala College 7


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Practical No : 2

What-if Analysis Using Excel and Power BI(14/12/23)

Demonstrate what-if analysis using goal seek, scenario manager and data table for your own data.

1. Goal Seek : This will find the right input value.


a. Semester and Grade points
Enter the below data

Select the CGPA value. Select the Goal Seek from What-If Analysis of Data tab.

Set the values in Goal Seek window

Ramniranjan Jhunjhunwala College 8


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

The result will be

b. Subject and Total


Enter the below data

Apply Goal Seek

The result will be

Ramniranjan Jhunjhunwala College 9


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

c. Academic year

Enter the below data

Find the total profit

Apply Goal Seek

Ramniranjan Jhunjhunwala College 10


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

The result will be

2. Scenario Manager : This will create different groups of values or scenarios and switch between them.
a. Room and Amount

Enter the below data

Select the value of Total Amount.


Select Scenario Manager from What-If Analysis of Data tab

Ramniranjan Jhunjhunwala College 11


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Click Add

Now add a scenario and select the value cell of No. of customers in the Changing cells textbox

Ramniranjan Jhunjhunwala College 12


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Now add second scenario


S2 scenario:

Enter value for the changing cells:

Select S2 scenario then click on show button to see the changes

Ramniranjan Jhunjhunwala College 13


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

b. Grain:
Enter the below data

Add scenario manager on value of Total named Monday where the rate of wheat will be change to 52 from 50

See the results by clicking show button

Ramniranjan Jhunjhunwala College 14


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Add second scenario named Tuesday where the rate of rice will be changed to 76 from 10

See the result

Ramniranjan Jhunjhunwala College 15


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Add a second scenario named Tuesday with the value of Rate /kg of Rice

Enter the changing value as 72

The results will be

Add the third scenario named Wednesday with the changing cell as the value of Rate /kg of Rice

Ramniranjan Jhunjhunwala College 16


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Enter the changing value as 76

The results will be

3. Data Table : Displays the results of multiple inputs at the same time

a. Stationary:

Enter the below data with the formula for total profit = B4*C4+B5*C5

Make another table to find the total highest price as shown below.
Select the value cells
Go to the Data tab, now select the Data Table from What-If Analysis.

Ramniranjan Jhunjhunwala College 17


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Enter the highest value of % sold as column input cell in the Data Table window.
Click OK

The results will be

Make another table

Apply Data Table to the above table

Ramniranjan Jhunjhunwala College 18


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Make changes in the Data Table window

The results will be

Ramniranjan Jhunjhunwala College 19


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

b. Compound Interest Calculator

Enter the below data with the formulae


● Balance = FV(B32/B33,B33*B34,,-B31)
● Interest = B35-B31

Now make a new table with the first value of Balance is equal to the value of Balance from original table

Apply Data Table to it with the defined column input cell

Ramniranjan Jhunjhunwala College 20


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

The results will be

Make another table

Apply Data Table to it as well and add column input cell as defined

Ramniranjan Jhunjhunwala College 21


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

The results will be

Make a table

Apply Data Table, add both row and column input cell value as defined

The results will be

Ramniranjan Jhunjhunwala College 22


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Practical No : 3

Creating Pivot Table and Pivot Chart using Excel and Power BI

Demonstrate the creation of one dimensional and two dimensional pivot table and pivot chart to perform
analysis using Microsoft Excel and PowerBI for any sample data like fruits sale data.

a. Microsoft Excel

Sale data:
Enter the below data

Ramniranjan Jhunjhunwala College 23


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Select the whole data and select the Table/Range from Pivot Table from Insert tab

Click OK

Ramniranjan Jhunjhunwala College 24


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

The results will be

Ramniranjan Jhunjhunwala College 25


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

To make bar chart:

Ramniranjan Jhunjhunwala College 26


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

b. Power BI

Load the sales data in power BI

Click on Report View

Ramniranjan Jhunjhunwala College 27


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Select Matrix option from Visualizations

Drag and drop values in rows and columns

Ramniranjan Jhunjhunwala College 28


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

A pivot table will be created

Now select Clustered column chart from Visualization

Ramniranjan Jhunjhunwala College 29


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Drag and drop values in X-axis and Y-axis

A chart will be created

Ramniranjan Jhunjhunwala College 30


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Practical No : 4

Import data from legacy data structures.

Import the legacy data from different sources such as (Excel, Web, XMl, etc) in PowerBi.

Import the legacy data from different data sources such as (Flat file, Excel, Web, XML, JSON, OData,etc.
Perform the extraction transformation and Loading (ETL) process to load in PowerBi)

Note: Use your data for Flat File ,Excel,Web, XMl,JSON, OData
File for oData - https://services.odata.org/v2/northwind/northwind.svc/

Open Power BI Desktop

Click on Get data

Ramniranjan Jhunjhunwala College 31


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

1. Flat file (.csv)

Save a file with .csv extension

Open Power BI and load the file

Ramniranjan Jhunjhunwala College 32


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

2. CSV file

Download iris.csv file from Google. Select File type Text/CSV from the Get Data window.

Select iris.csv file. Click on Load button

The screen will look like this

Ramniranjan Jhunjhunwala College 33


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

By clicking on Data, you can see iris data set

3. Excel file

Select Excel workbook option from Get Data

Ramniranjan Jhunjhunwala College 34


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Load Stud_info.xlsx :

4. XML document

Ramniranjan Jhunjhunwala College 35


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Select XML

Ramniranjan Jhunjhunwala College 36


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

5. OData
File for oData - https://services.odata.org/v2/northwind/northwind.svc/

Ramniranjan Jhunjhunwala College 37


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

6. Web

Ramniranjan Jhunjhunwala College 38


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

7. Json

Ramniranjan Jhunjhunwala College 39


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Practical No : 5

ETL and Data Modeling in Power BI

Perform Extract , Transformation, Loading process to construct the database in Power BI.

Create a data model for the student database in PowerBI and import data from excel worksheet. Also perform
ETL and prepare data for result analysis.

ETL on Stud_info.xlsx :

Load Stud_info.xlsx :

Now we can click Transform button

Ramniranjan Jhunjhunwala College 40


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

First we need to change the format of student names. For that select Capitalize Each Word from Format of
Transform tab.

Before : After :

Also we need to change the format of the students department. Similar steps need to be followed, but instead
of Capitalize Each Word we need to select UPPERCASE from the Format of Transform tab.

Before : After :

Ramniranjan Jhunjhunwala College 41


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Now we need to change the Roll Nos from 1-5 to 6433-6437. For that, select the first value of Roll No column
and select Replace Values from the Replace Values of Transform tab.

Enter the value

Before : After :

Repeat the steps. Final values of Roll No column

Ramniranjan Jhunjhunwala College 42


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

We have performed the following transformation on Stud_Info.xlsx

Save the changes

Ramniranjan Jhunjhunwala College 43


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

The transformation is saved successfully and also loaded successfully.

ETL on iris.csv

We can perform several operations, some of them are:


1) Sort by column

2) Data groups

Ramniranjan Jhunjhunwala College 44


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Choose the value to be grouped

The results will be

We can also change the Currency of value in a column

Ramniranjan Jhunjhunwala College 45


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

3) We can also select the columns to be displayed

4) Split Column

Ramniranjan Jhunjhunwala College 46


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

The results will be

We can now save our work

Now we can click Transform button

Ramniranjan Jhunjhunwala College 47


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

There are several operations that we can perform


1) Transpose

2) Reverse

3) Transform and Upper case

4) Replace value

Ramniranjan Jhunjhunwala College 48


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College 49


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Practical No : 6

Creating Reports and Charts in Power BI

Demonstrate the report creation in Power BI for data of any subject. (For ex: Financial Sample and Retail
Data)

1. Perform

Q.1. Load Financial Sample data into the PowerBI

Ramniranjan Jhunjhunwala College 50


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Q.2. Create the Data Model by relating all the tables if possible

Ramniranjan Jhunjhunwala College 51


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Q.3. Open Financial Data table for Transformation

Ramniranjan Jhunjhunwala College 52


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Q.4. Transform ‘Units Sold’ Columns data by changing its data type to whole number
Before: After:

Ramniranjan Jhunjhunwala College 53


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Q.5. Transform segment column data to uppercase.


Before:

After:

Q.6. Shorten the column name from month name to just month

Before:

Ramniranjan Jhunjhunwala College 54


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

After:

Q.7. The product Montana did not continue last month. So exclude the data of the Montana product from the
table by deselecting the product from the column filter.
Before:

Ramniranjan Jhunjhunwala College 55


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

After:

Q.8. You see that each data transformation has been added to the list Query Settings in Applied Steps.

Q.9. Back on the home tab, select close and apply.

Ramniranjan Jhunjhunwala College 56


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

2. Writing DAX Expressions

Q. Create a new measure named Total Units Sold to add all the numbers in the Unit Sold column.

On the Home ribbon, select New measure

Type the following expression.


Total units sold = SUM(financials[Units Sold])
Select the check mark beside expression box to commit the expression

Go to Home tab → Select a bar chart from Visualizations → Click Total Units Sold from Fields

Ramniranjan Jhunjhunwala College 57


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

3. Create new table in data model

Q. Create a new table named ‘Calendar’ to generate a Calendar table of all dates between January 1 2013, and
December 31, 2014.

Select the Data view on the left

On the Home ribbon, select New table

Type the following expression, in expression box:


Calendar = CALENDAR(DATE(2013,01,01), Date(2014,12,31))

Ramniranjan Jhunjhunwala College 58


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Select the model view on the left

Update data model to link Finances table Date to Date Table Date.

Ramniranjan Jhunjhunwala College 59


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

4. Add report title as “Executive Summary – Finance Report”

On the Home ribbon, select the Text Box to add title to the report and type “Executive Summary - Finance
Report”.

Select the text you typed. Set the Font Size to 20 and Bold. Resize the box to fit on one line.

Q. To check Profit by Date, add a line chart to see which month and year had the highest profit.

From the Fields pane, drag the Profit field to a blank area on the report canvas. By default, Power BI displays
a column chart with one column, Profit. Drag the Date field to the same visual. If you created a Calendar table
in Extra credit: Create a table in DAX earlier in this article, drag the Date field from your Calendar table
instead. Power BI updates the column chart to show profit by the two years.

Ramniranjan Jhunjhunwala College 60


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

In the Fields section of the Visualizations pane, select the drop-down in the X- axis value. Change Date from
Date Hierarchy to Date.
Power BI updates the column chart to show profit for each month.

Ramniranjan Jhunjhunwala College 61


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Q. Change the visualization type to Line chart. (In the Visualizations pane change the chart type)

Q. Create a map visual to check the high profit Country or Region.

From the Fields pane, drag the Country field to a blank area on your report canvas to create
a map.
Drag the Profit field to the map.
Power BI creates a map visual with bubbles representing the relative profit of each location.
Compare the bubble size to identify the highest profit country.

Ramniranjan Jhunjhunwala College 62


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Q. Create a bar chart to check sales by product and segment and determine which companies and segments to
invest in.

Drag the two charts you’ve created to be side by side in the top half of the canvas.
Save some room on the left side of the canvas.
Select a blank area in the lower half of your report canvas.
In the Fields pane, select the Sales, Product, and Segment fields.
Power BI automatically creates a clustered column chart.
Drag the chart so it’s wide enough to fill the space under the two upper charts.

Ramniranjan Jhunjhunwala College 63


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Q. Add date slicer to the report to check or filter the year wise or month wise data.

In the Fields pane, select the Date field in the Financials table. Drag it to the blank area on the left of the
canvas.
In the Visualizations pane, choose Slicer. Power BI automatically creates a numeric range slicer.

You can drag the ends to filter, or select the arrow in the upper-right corner and change it to a different type of
slicer.

Ramniranjan Jhunjhunwala College 64


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Date slicer using the DAX table


In the Fields pane, select the Date field in the Calendar table. Drag it to the blank area on the left of the
canvas.
In the Visualizations pane, choose Slicer.
In the Fields section of the Visualisations pane, select the drop-down in Fields. Remove Quarter and Day so
only Year and Month are left.

Expand each year and resize the visual, so all months are visible.

Ramniranjan Jhunjhunwala College 65


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

We’ll use this slicer in the finished report.


Now if your manager asks to see just 2013 data, you can use either slicer to select years, or specific months of
each year.

Ramniranjan Jhunjhunwala College 66


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

5. Format Visuals to give a professional look to your report.

Use View → Change theme to Executive.


Or use format options to change foreground or background colours.

Ramniranjan Jhunjhunwala College 67


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Practical 7

Creating Dashboards in Power BI

Demonstrate the creation of a dashboard in Power BI for data of any subject.

Open Power BI

Upload the data:

Ramniranjan Jhunjhunwala College 68


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Go to the Report View

You will see this screen

Under Visualization → Click on Format your report Page

Ramniranjan Jhunjhunwala College 69


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Under Visualization → Format your report page → Canvas Background → Change the background color.

Insert →Shapes →Rounded Rectangle

Do the formatting as per your need and also set text

Ramniranjan Jhunjhunwala College 70


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Then create a rounded square shape and do the formatting of it

Create as many as you want

Ramniranjan Jhunjhunwala College 71


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Now create a new Table in which we will execute all our measures that will be used further in the dashboard.
Under Home Section → Enter Data.

This window will be open, Name: All Measures.

As you can see the new Table with one Column1 is created under Data.

Ramniranjan Jhunjhunwala College 72


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Right click on Column1 → create a New Measure.

Under New Measure write the DAX Query as shown below. Use the CountRows function of DAX Query to
count the rows in the table.
Total Customer = COUNTROWS('6433_Mall_Customers')

Now again create a new measure and then use the DAX Query to query the data according to it.

Ramniranjan Jhunjhunwala College 73


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Write the following queries in it.

Male = CALCULATE([Total Customer], '6433_Mall_Customer'[Gender]="Male")

Female = CALCULATE([Total Customer], '6433_Mall_Customer'[Gender]="Female")

% male = DIVIDE([Male],[Total Customer],0)

% female = DIVIDE([Female],[Total Customer],0)

Ramniranjan Jhunjhunwala College 74


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Check the Total Customer checkbox, a stacked column chart will be displayed as below

Since we want only the value, we will use Card

Ramniranjan Jhunjhunwala College 75


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Do the formatting and set it into the first square box also add a text into it

Repeat the similar process.

Ramniranjan Jhunjhunwala College 76


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Add image using the Image option from Insert tab

Place them in right places

Now, click on Clustered Column chart

Ramniranjan Jhunjhunwala College 77


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Drag and drop the Age column in X-axis and Male and Female measures in Y-axis

Ramniranjan Jhunjhunwala College 78


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

By clicking on a bar, we can find the total no. of customers, no. of male customers and no. of female
customers

Now, add a new page, before that rename our first page as Home

Name the second page as Spending and Income

Copy the above two rounded rectangles from the Home Dashboard and paste it in the Spending and Income
Dashboard. Also select a clustered column chart as we did in the Home page. Select Spending Score(1-100)
column in X-axis and Max of Annual Income (k$). Do the formatting as per need.

Ramniranjan Jhunjhunwala College 79


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Our Spending and Income Dashboard will look like this.

For navigating between the dashboards, we will now add a Blank Button from Insert tab

Write a text and do the formatting

Ramniranjan Jhunjhunwala College 80


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Enable the Action option, select Page Navigation for Type and None (because we are adding this button in the
Spending and Income Dashboard itself) in Destination.

Likewise make another button in Spending and Income Dashboard, give it a text named Home, set its action
type as Page Navigation and select Home in Destination

Do the same things in Home Dashboard, be careful while selecting the Destination for each buttons

Ramniranjan Jhunjhunwala College 81


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Our final Home Dashboard looks like this


For navigating to Spending and Income Dashboard, Ctrl and click the Spending and Navigation button

Our final Spending and Income Dashboard looks like this


For navigating to Home Dashboard, Ctrl and click the Home button

Ramniranjan Jhunjhunwala College 82


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Practical No : 8

DAX Queries in Power BI

Execute the following DAX queries on food sales data.

Load the necessary datasets

1. Create a measure to display quarter wise sum of sales amount


Previous Quarter Sales =
CALCULATE(SUM(Sales[SalesAmount]),PREVIOUSQUARTER(Calendar[DateKey]))

Ramniranjan Jhunjhunwala College 83


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Click on Commit

A new measure is created

Go to Report view

Ramniranjan Jhunjhunwala College 84


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Select a Stacked column chart

Drag and drop the following fields

Ramniranjan Jhunjhunwala College 85


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

2. Create a measure to display Minimum sales amount (Sales Amount)


By similar process, create a new measure with the below DAX query
Minimum Sales Amount = MIN(Sales[SalesAmount])

Similarly make a stacked column chart for minimum sale amount.

We can also display the minimum value using a card visualisation tool.

Ramniranjan Jhunjhunwala College 86


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

3. Create a measure to display maximum sales amount (Sales Amount)


Maximum sales amount = MAX(Sales[Sales Amount])

Ramniranjan Jhunjhunwala College 87


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

4. Display maximum product cost of product.


Max Cost = MAX(Product[UnitCost])

5. Display a measure to count distinct brand names.


Distinct brand = COUNTROWS(DISTINCT('Product'[BrandName]))

Ramniranjan Jhunjhunwala College 88


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

6. Create a measure to display the total of blank values for product manufacturers.
Blank values = CALCULATE(COUNTROWS('Product'), ISBLANK('Product'[Manufacturer]))

Since there is no blank values, the count is null

Ramniranjan Jhunjhunwala College 89


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Practical No : 9 (30/01/24)

Implementation of Regression Algorithms using Python

Create a BI folder in your drive. Now right click and select Google Colaboratory option

An untitled Google colab notebook will open

Rename it as 6433_DataAnalysisUsingPython

Ramniranjan Jhunjhunwala College 90


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

We can also execute linux commands, the commands should precede an exclamation mark (!)

We can also use file icon to check the directories and files

Ramniranjan Jhunjhunwala College 91


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Right click on sample_data directory and select upload option to upload a .csv file. Double click on the .csv
file to see its data.

Simple practice:

1. int variable

2. String variable

3. list with integer values

Ramniranjan Jhunjhunwala College 92


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

4. list with string values

5. array
1D array with multiple values:

Ramniranjan Jhunjhunwala College 93


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

1D array with single value:

2D array
Column,row

3D array:
Array,row,column

Ramniranjan Jhunjhunwala College 94


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

reshape() of 1D array

matmul() :

dot() :

Ramniranjan Jhunjhunwala College 95


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

add()

add function

a. Simple Linear Regression


Problem Statement - Given the datasetsal2.csv that has two variables: salary (dependent variable) and
experience (Independent variable) solve the following queries :

Ramniranjan Jhunjhunwala College 96


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Upload the dataset.

Importing libraries

Loading the csv file

Ramniranjan Jhunjhunwala College 97


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Extracting dependent and independent variables from the dataset. for x variable, we have taken -1 value since
we want to remove the last column from the dataset and for y variable, we have taken 1 value as a parameter,
since we want to extract the second column and indexing starts from the zero.

Values of x and y :

1. Find out if there is any correlation between two variables: salary and experience.

Ramniranjan Jhunjhunwala College 98


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

2. Find the best fit line for the dataset.

Ramniranjan Jhunjhunwala College 99


Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


100
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

3. Demonstrate how the dependent variable is changing by changing the independent variable.
y = mx + c [where m is coefficient or slope and c is intercept]

Method 1:

Ramniranjan Jhunjhunwala College


101
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Method 2 :

Example of simple linear regression

Example 1

Creating an object named model of LinearRegression() class

fit() method takes the training data as arguments. Used to train a machine learning model on a given dataset.

Ramniranjan Jhunjhunwala College


102
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

intercept_ is the value at which the regression line crosses the y-axis.

coef_ returns an array of the coefficients of the linear regression equation.

score() calculates accuracy of model.

predict() is used to make predictions on new data, based on a trained model. It accepts one argument, the new
data X_new, and returns the learned label for each object in the array.

Pyplot is a submodule of Matplotlib, a Python library used to create data visualisations. Pyplot provides a
number of functions for creating and manipulating plots

Ramniranjan Jhunjhunwala College


103
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

scatter() will create a scatter plot

Ramniranjan Jhunjhunwala College


104
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Example 2

Ramniranjan Jhunjhunwala College


105
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


106
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


107
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Example 3

Ramniranjan Jhunjhunwala College


108
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


109
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

b. Multiple Linear Regression

Problem Statement - Given a dataset complist.csv of 50 start-up companies with five main attributes: R&D
Spend, Administration Spend, Marketing Spend, State, and Profit for a financial year, create a model that can
easily determine which company has a maximum profit, and which is the most affecting factor for the profit of
a company.

Upload the dataset:

Ramniranjan Jhunjhunwala College


110
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


111
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


112
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Example of multiple linear regression data.csv file

Upload the data.csv file

Ramniranjan Jhunjhunwala College


113
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


114
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


115
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Practical No : 10

Problem Statement: Classify the iris species by using the following algorithms. (Given Dataset: iris.csv)

a. Logistic Regression :
Logistic regression is a linear model that can be used to model the probability of a binary outcome. It uses a
sigmoid function to map the linear combination of the input features to a value between 0 and 1, which can be
interpreted as the likelihood of the positive class.

Upload the dataset

Ramniranjan Jhunjhunwala College


116
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


117
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


118
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

b. K-Nearest Neighbors (KNN) :


K-nearest neighbours (KNN) is a non-parametric algorithm that can be used to classify an observation based
on the majority vote of its k closest neighbours in the feature space.

c. Naive Bayes :
Naive Bayes is a probabilistic algorithm that can be used to classify an observation based on the Bayes’
theorem and the assumption of conditional independence among the input features. It calculates the posterior
probability of each class given the observation and chooses the class with the highest probability

Ramniranjan Jhunjhunwala College


119
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

d. Decision Tree :
Decision tree is a hierarchical algorithm that can be used to classify an observation based on a series of rules
derived from the input features. It splits the data into subsets based on the best feature and threshold at each
node, until a leaf node is reached that contains only one class or a predefined minimum number of samples.

Ramniranjan Jhunjhunwala College


120
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

e. Support Vector Machine :


Support vector machine (SVM) is a linear or non-linear model that can be used to classify an observation
based on the maximum margin hyperplane that separates the classes in the feature space. It uses a kernel
function to map the input features to a higher dimensional space where the data is more likely to be linearly
separable.

Ramniranjan Jhunjhunwala College


121
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Practical No : 11

Implementation of Clustering Algorithms using Python

a. K-Mean Cluster
Given a dataset of Mall_Customers, which is the data of customers who visit the mall and spend there,
implement the k-means clustering algorithm.

Upload the dataset

Ramniranjan Jhunjhunwala College


122
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


123
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


124
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


125
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

b. Agglomerative Clustering
Implement agglomerative hierarchical clustering algorithm using Python for Mall_customer dataset.The
dataset contains the information of customers that have visited a mall for shopping. So, the mall owner wants
to find some patterns or some particular behaviour of his customers using the dataset information. (Dataset:
Mall_Customers.csv)

Ramniranjan Jhunjhunwala College


126
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


127
Name : Khan Ariba Mohammed Hakim BI Journal
Roll No : 6433

Ramniranjan Jhunjhunwala College


128

You might also like