Da Lab Part A B C
Da Lab Part A B C
Da Lab Part A B C
KLESNC Rajajinagar
LAB PROGRAM -1
1. Apply conditional formatting to highlight employees with high salary greater than
50,000
2. Use the IF function to categorize employees into "High Performers" or
"Average Performers" based on their sales.
3. Use COUNTIF, SUMIF, and AVERAGE to calculate statistics like no of
employees working in each department and sum of their salaries and average of
their Salaries, average Salary of total employees.
4. Create a new column using CONCAT to combine the employee's name
and department.
COUNTIF Function
KLESNC Rajajinagar
SUMIF Function
The condition is referred to as criteria, which can check things like: >, <, >=,
<=,==, !=
AVERAGE Function
CONCAT Function
Example of delimiters
comma, semicolon ; quotes " or ' braces {} pipes | slashes / \
KLESNC Rajajinagar
1) Conditional formatting rule:
Conditional formatting is used to change the appearance of cells in a range based
on your specified conditions.
KLESNC Rajajinagar
2. Use the IF function to categorize employees into "High Performers" or
"Average Performers" based on their sales.
=IF(E2>50000;"HIGH Performers";"Average_performers")
KLESNC Rajajinagar
4. Calculate the average salaries in each department.
=AVERAGEIF (D$2:D$22;F2;E$2:E$22)
5. Create a new column using CONCAT to combine the employee's name and
SALARY
=CONCATENATE (A2;"---"; E2)
KLESNC Rajajinagar
LAB PROGRAM 2
KLESNC Rajajinagar
INDEX:
The INDEX function returns a value or the reference to a value from within a table or range.
Syntax: INDEX (array, row_num, [column_num])
The array form of the INDEX function has the following arguments:
Array Required. A range of cells or an array constant.
If array contains only one row or column, the corresponding row_num or column_num argument
is optional.
If array has more than one row and more than one column, and only row_num or column_num is
used, INDEX returns an array of the entire row or column in array.
row_num Required, unless column_num is present. Selects the row in array from which to
return a value. If row_num is omitted, column_num is required.
column_num Optional. Selects the column in array from which to return a value. If
column_num is omitted, row_num is required.
1. Calculate Value at the intersection of the 2nd row and 2nd column in the range
A3:D12 & Value at the intersection of the 3rd row and 4th column in the range
A3:D12 &use Index and match function to retrieve the sales of the specific employee
based upon their name.
=INDEX(A3:D12;2;2)
=INDEX(A3:D12;3;4)
=INDEX(D3:D12;MATCH("Lana";A3:A12;0))
MATCH function:
The MATCH function searches for a specified item in a range of cells, and then returns the relative
position of that item in the range.
Syntax: MATCH (lookup_value, lookup_array, [match_type])
lookup_value Required. The value that you want to match in lookup_array.
lookup_array Required. The range of cells being searched.
match_type Optional. The number -1, 0, or 1.
KLESNC Rajajinagar
Match_type DESCRIPTION
1 or omitted MATCH finds the largest value that is less than or equal to lookup_value.
The values in the lookup_array argument must be placed in ascending order, for example:
1, 0, 1, 2, ..., A-Z, FALSE, TRUE.
0 MATCH finds the first value that is exactly equal to lookup_value. The values in
the lookup_array argument can be in any order.
-1 MATCH finds the smallest value that is greater than or equal to lookup_value.
The values in the lookup_array argument must be placed in descending order, for examp
TRUE, FALSE, Z-A, ...2, 1, 0, -1, -2, ..., and so on.
2. Match is used to find out Order value is present in the table or not
=MATCH(99;C3:C12;1)
=MATCH(140;C3:C12;0)
=MATCH(33000;D3:D12;-1)
IFS Function:
Use the IFS function to check whether one or more conditions are met and
returns a value that corresponds to the first TRUE condition.
IFS can take the place of multiple nestedIF statements, and is much easier
to read with multiple conditions.
Syntax:
= IFS(logical_test1, Value1 [logical_test2, Value2] …, [logical_test127, Value127])
3. Using Ifs Statement to Categorize the Sales Performance
=IFS (C3>90, "A", C3>80, "B", C3>70, "C",C3>60, "D")
KLESNC Rajajinagar
UNIQUE:
Syntax: =UNIQUE(array,[by_col],[exactly_once])
Array (required) - the range or array from which to return unique values.
By_col (optional) - a logical value indicating how to compare data:
o TRUE - compares data across columns.
o FALSE or omitted (default) - compares data across rows.
Exactly_once (optional) - a logical value that defines what values are considered
unique:
o TRUE - returns values that occur only once, which is the database notion
of unique.
o FALSE or omitted (default) - returns all distinct (different) values in the
range or array.
4. Use Unique function to create the List Unique regions
=UNIQUE(B3:B12)
=unique(B3:D4,false) /* Compress data across rows*/
=unique(C9:D9,True) /* Compress data across Columns*
KLESNC Rajajinagar
COUNTIFS:
The COUNTIFS function is a premade function in Excel, which counts cells in a range
based on one or more true or false condition.
Syntax =COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)
The criteria_range1, criteria_range2, and so on, are the ranges where the function check
for the conditions.
If a number is greater than another number >
If a number is smaller than another number <
If a number or text is equal to something =
SUMIFS Function :
The SUMIFS function is a premade function in Excel, which calculates the sum of a
range based on one or more true or false condition.
It is typed =SUMIFS:
Syntax=SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2] ...)
The criteria_range1, criteria_range2, and so on, are the ranges where the function check
for the conditions.
If a number is greater than another number >
If a number is smaller than another number <
If a number or text is equal to something =
The [sum_range] is the range where the function calculates the sum.
AVERAGEIFS Function:
The AVERAGEIFS function is a premade function in Excel, which calculates the average of a
range based on one or more true or false condition.
It is typed =AVERAGEIFS:
=AVERAGEIFS (average_range, criteria_range1, criteria1, ...)
The criteria_range1, criteria_range2, and so on, are the ranges where the function check for the
conditions.
If a number is greater than another number >
If a number is smaller than another number <
KLESNC Rajajinagar
If a number or text is equal to something =
The average_range is the range where the function calculates the average.
5. Use COUNTIFS, SUMIFS, AverageIFS, functions to calculate statistics based on
multiple Criteria, such as region, orders (>=50), sales.
=COUNTIFS(B$3:B$10;E3;C$3:C$10;F3)
=SUMIFS(D$3:D$10;B$3:B$10;E3;C$3:C$10;F3
=AVERAGEIFS(D$3:D$23;B$3:B$23;E3;C$3:C$23;F3)
KLESNC Rajajinagar
LAB PROGRAM 3
VLOOKUP, HLOOKUP, XLOOKUP, COUNT, COUNTA
VLookup In Excel :
This stands for the vertical lookup that is responsible for looking for a particular value in the
leftmost column of a table. It then returns a value in the same row from a column you specify.
Syntax: VLOOKUP( lookup_value, table_array, col_index_num,[range_lookup]
lookup_value - This is the value that you have to look for in the first column of a table.
table - This indicates the table from which the value is retrieved.
col_index - The column in the table from the value is to be retrieved. The Count Of first
Column is always 1.
range_lookup - [optional] to find an Exact match enter False To find an appropriate
match enter True.
TRUE = approximate match (default). FALSE = exact match.
1. Now use VlookUp to find Orders of a Specific Employee Based on their name.
=VLOOKUP(A2;A1:E8;3)
=VlookUp (“Agatha”;A1:H22;6)
XLOOKUP :
The XLOOKUP function searches a range or an array, and then returns the item corresponding to
the first match it finds. If no match exists, then XLOOKUP can return the closest (approximate)
match.
Syntax=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found],
[match_mode], [search_mode])
KLESNC Rajajinagar
Optional If a valid match is not found, and [if_not_found] is missing, #N/A is returned.
[match_mode] Specify the match type:
Optional 0 - Exact match. If none found, return #N/A. This is the default.
3. Use Xlookup to find the Unit Price of a product based on their order id in
Horizontal Table.
=XLOOKUP(“105,B1:F1,B3:F3)
KLESNC Rajajinagar
COUNT Explanation:
The COUNT function is generally used to count a range of cells containing numbers or
dates excluding blanks.
Syntax: COUNT (value1, [value2], ...)
The COUNT function syntax has the following arguments:
Value1 Required. The first item, cell reference, or range within which you want to count
numbers.
Value2, ... Optional. Up to 255 additional items, cell references, or ranges within which
you want to count numbers.
=COUNT(B2:B14)
CountA Function :
The COUNTA function counts the number of cells that are not empty in a range.
Syntax:
COUNTA(value1, [value2], ...)
The COUNTA function syntax has the following arguments:
value1 Required. The first argument representing the values that you want to count.
value2, ... Optional. Additional arguments representing the values that
you want tocount, up to a maximum of 255 arguments.
The COUNTA function counts cells containing any type of information,
including error values and empty text (""). For example, if the range
contains a formula that returns an empty string, the COUNTA function
counts that value.
The COUNTA function does not count empty cells.
=COUNTA(B2:B14)
KLESNC Rajajinagar
Hlookup Function:
HLOOKUP in Excel stands for ‘Horizontal Lookup’. It is a function that makes Excel
search for a certain value in a row (the so called ‘table array’), in order to return a value
from a different row in the same column.
Syntax: HLOOKUP([value], [range], [row number], [false or true])
The value you want to look up;
The range in which you want to find the value and the return value;
The number of the row within your defined range, that contains the return value;
0 or FALSE for an exact match with the value your are looking for; 1 or TRUE for an
approximate match.
4. Hlookup Function is used to find out Department of a Specific Employee based
on their name.
KLESNC Rajajinagar
Lab Program: 4
KLESNC Rajajinagar
RIGHT Function:
The function will return a specified number of characters from the end of a given text
string.
In doing financial analysis, the RIGHT function can be useful if we wish to extract
characters from the right side of a text string. Generally, it is used by combining it with
other functions such as VALUE, SUM, COUNT, DATE, DAY, etc.
Syntax:
=RIGHT (text,[num_chars])
BEN-2345
JOHN-5432
BHT-5645
1. We wish to extract the last 4 characters, the order number. The formula to use will be
=VALUE(RIGHT(C2;4))
MID Function:
Generally speaking, the MID function in Excel is designed to pull a substring
from the middle of the original text string.
The Excel MID function has the following arguments:
= MID(text, start_num, num_chars)
Where:
Text is the original text string.
Start_num is the position of the first character that you want to extract.
Num_chars is the number of characters to extract.
KLESNC Rajajinagar
All 3 arguments are required.
1. For example, to pull 3 characters from the text string in A2, starting with the 2nd
character, use this formula:
=MID (A2;2;3)
LEN Function:
LEN returns the number of characters in a text string.
Syntax:
LEN (text)
Text Required. The text whose length you want to find. Spaces count as characters.
=LEN (A2)
SEARCH Function:
The SEARCH functions locate one text string within a second text string, and return the
number of the starting position of the first text string from the first character of the
second text string.
Syntax: SEARCH(find_text,within_text,[start_num])
o find_text Required. The text that you want to find.
o within_text Required. The text in which you want to search for the value of
the find_text argument.
o start_num Optional. The character number in the within_text argument at
which you want to start searching.
For example, to find the position of the letter "n" in the word "printer", you can use the
following function:
o =SEARCH("n","printer")
This function returns 4 because "n" is the fourth character in the word "printer."
You can also search for words within other words. For example, the function
o =SEARCH("base","database")
KLESNC Rajajinagar
ISNUMBER Function:
The function checks if a cell in Excel contains a number or not. It will return
TRUE if the value is a number and if not, a FALSE value.
For example, if the given value is a text, date, or time, it will return FALSE.
o Syntax: =ISNUMBER (value)
The Excel ISNUMBER function uses the following arguments:
o Value (required argument) – This is the expression or value that
needs to be tested. It is generally provided as a cell address.
o The ISNUMBER Excel function will return a logical value, which
is TRUE or FALSE.
Example 1: Let’s first understand how the function behaves using the following set of data:
=ISNUMBER (A2)
SUBSTITUTE Function:
Substitutes new_text for old_text in a text string. Use SUBSTITUTE when you want to
replace specific text in a text string; use REPLACE when you want to replace any text
that occurs in a specific location in a text string.
Syntax :
=SUBSTITUTE(text, old_text, new_text, [instance_num])
The SUBSTITUTE function syntax has the following arguments:
Text Required. The text or the reference to a cell containing text for which
you want to substitute characters.
Old_text Required. The text you want to replace.
KLESNC Rajajinagar
New_text Required. The text you want to replace old_text with.
Instance_num Optional. Specifies which occurrence of old_text you want
to replace with new_text. If you specify instance_num, only that instance of
old_text is replaced. Otherwise, every occurrence of old_text in text is
changed to new_text.
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet.
o Sales Data
o Quarter 1, 2008
o Quarter 1, 2011
=SUBSTITUTE(D3, "1", "2", 1) Substitutes first instance of "1" with "2" (Quarter 2, 2008) Quarter 2, 2008
=SUBSTITUTE(D4, "1", "2", 3) Substitutes third instance of "1" with "2" (Quarter 1, 2012) Quarter 1, 2012
KLESNC Rajajinagar
Lab Program -5
TODAY, NOW, YEAR, MONTH, NETWORKDAYS, EOMONTH
Today Function:
The TODAY function returns the serial number of the current date in Excel. The TODAY
function updates automatically whenever the worksheet is opened, or when the formulas are
manually recalculated.
Syntax
The TODAY function has no arguments.
The format is: = TODAY()
NOW Function:
The NOW function in Excel returns the serial number of the current date and time. The
NOW function is considered ‘volatile’, meaning that it updates automatically whenever the
worksheet is opened, or when the formulas are manually recalculated.
Syntax
The NOW function has no arguments.
The format is: =NOW()
And ADD days to current date by using =NOW()+7
YEAR Funmction:
The YEAR function returns the year corresponding to a date. This can be useful for
isolating the year element of a date.
Syntax
The syntax of the YEAR function is: =YEAR(Serial_number)
Serial_number is the Excel-assigned number of the date you want to query. The serial
number is usually obtained as the result of another Excel function, such as TODAY, DATE,
DATEVALUE, etc.
DATE FORMULA RESULT
12-Jan-98 =YEAR(A2) 1998
12/09/23 =year(A3) 2023
20,Jan,2005 =year(DATEVALUE(A4)) 2005
03/12/23 =year(today()) 2023
2005,6,12 =year(date(2005,6,12)) 2005
KLESNC Rajajinagar
MONTH Function:
The MONTH function returns the nth month of the year ranging from 1 to 12. This can be
useful for isolating the month element of a date. Or Returns the month of the year a specific
date falls in, in numeric format.
Syntax
The syntax of the MONTH function is: =MONTH (Serial_number)
Serial_number is the Excel-assigned number of the date you want to query. The serial number is
usually obtained as the result of another Excel function, such as TODAY, DATE, DATEVALUE, etc.
NETWORKDAYS Function :
NETWORKDAYS is used to determine the number of working days between two dates.
The formula calculates the days in an inclusive manner, meaning that the start and end days
are included in the count, and Saturdays and Sundays are automatically excluded from the
calculation. Additional or ad hoc days may also be excluded using an optional argument.
KLESNC Rajajinagar
2. =NETWORKDAYS(D9;E9) # no of working days b/w 1/12/23 to 31/12/23
3. =NETWORKDAYS(D9;E9;A13) # no of working days b/w 1/12/23 to 31/12/23 and
25/12/23 is holiday as Non working day.
EOMONTH FUNCTION:
The EOMONTH function determines the last day of an earlier or later month than the
month being referenced.
The EOMONTH function may be used to determine maturity, expiry, or due dates when we
want to force these to fall on the last day of the month.
This function returns the serial number of the calculated date, which can then be formatted
using the date format of choice.
Syntax
o EOMONTH(start_date,months)
o Start_date will be used as the reference date.
o Months is the number of months to be calculated before or after the start_date.
=EOMONTH(A13;36)
o In the above example, the investment is set to mature on the last date of the month,
three years from the investment date.
=EOMONTH(A14;0.9)
o If a number other than an integer is entered in months, EOMONTH truncates the
decimal and uses the whole number value only (see below).
=EOMONTH(A18;-1)
o Months can also be entered as a negative value, which will result in subtracting that
number of months from the start date, as shown below.
KLESNC Rajajinagar
KLESNC Rajajinagar
LAB PROGRAM 6: OFFSET, CHOOSE, LET, MAX, SORT, SORTBY, RANK
OFFSET Function: The OFFSET function in Excel returns a cell or range of cells that is a given
number of rows and columns from a given cell or range.
The syntax of the OFFSET function is as follows:
OFFSET (reference, rows, cols, [height], [width])
The first 3 arguments are required and the last 2 are optional.
Required arguments:
Reference - a cell or a range of adjacent cells from which you base the offset. You can think of it
as the starting point.
Rows - The number of rows to move from the starting point, up or down. If rows is a positive
number, the formula moves below the starting reference, in case of a negative number it goes
above the starting reference.
Cols - The number of columns you want the formula to move from the starting point. As well as
rows, cols can be positive (to the right of the starting reference) or negative (to the left of the
starting reference).
Optional arguments:
Height - the number of rows to return.
Width - the number of columns to return.
Both the height and width arguments must always be positive numbers. If either is omitted, it
defaults to the height or width of reference.
OFFSET formula example:
=OFFSET(A1,3,1)
KLESNC Rajajinagar
1. =offset (A1,4,1)
2. =offset (A1,E2,1)
3. =offset (A9,-1,1)
4. =offset (A12,3,1,1,3)
5. =sum(offset(A12,3,1,1,3))
Choose function:
The Excel CHOOSE function returns a value from a list using a given position or index.
Syntax
=CHOOSE (index_num,value1,[value2],...)
index_num - The value to choose. A number between 1 and 254.
value1 - The first value from which to choose.
value2 - [optional] The second value from which to choose.
Choose formula example:
=choose(if(A2=5,1,if(A2=4,2,if(A2=3,3,if(A2=2,4,5)))),"Excellent","GOOD","Average","Poor","Terrible")
KLESNC Rajajinagar
LET FUNCTION:
The Excel LET function allows you to assign names to calculation results and define variables
inside a formula, so that the formula looks clearer and works faster.
Syntax
LET has the following syntax and arguments:
LET (name1, name_value1, [name2], [name_value2], …, calculation)
Where:
Name1 (required) - the first name to assign. It must begin with a letter.
Name_value1 (required) - the value or calculation assigned to name1.
Name2 / name_value2 (optional) - the second name and value.
Calculation (required) - a calculation that uses assigned names and values.
The function can process up to 126 name/value pairs.
LET Function Formula:
=let(x,B2,y,B3,x*y) or =LET(x, 2, y, 5, x*y)
MAX Function:
The MAX function is a premade function in Excel, which finds the
highest number in a range. The function ignores cells with text. It will
only work for cells with numbers.
Note: There is another function called MIN, which finds the lowest value in a
range, the opposite of MAX.
How to use the =MAX function:
Type =MAX
Double click the MAX command
Select a range (C2:C7)
Hit enter
Formula : = Max(C2:C7)
KLESNC Rajajinagar
Excel Sorting:
Ranges can be sorted using the Sort Ascending and Sort Descending commands.
Sort Ascending: from smallest to largest.
Sort Descending: from largest to smallest.
The sort commands work for text too, using A-Z order.
Note: To sort a range that has more than one column, the whole range has to be selected.
Sorting just one can breaks the relationship between columns.
Sort in the range A2:D22 by their Name, ascending from smallest to largest (A-Z).
1. Select A2:D22
2. Open the Sort & Filter menu
3. Click Sort Ascending
Note: A1 is not included as it is the header for the column. This is the row that is dedicated to
the filter. Including it will blend it with the rest.
=sort (A2:D22)
KLESNC Rajajinagar
Sortby Function :
The SORTBY function in Excel is designed to sort one range or array based on the values in
another range or array. Sorting can be done by one or multiple columns.
SYNTAX:
SORTBY (array, by_array1, [sort_order1], [by_array2, sort_order2],…)
Array (required) - the range of cells or array of values to be sorted.
By_array1 (required) - the range or array to sort by.
Sort_order1 (optional) - the sorting order:
1 or omitted (default) - ascending
-1 – descending
Important note! Currently the SORTBY function is only available with Microsoft 365
subscriptions and Excel 2021. In Excel 2019, Excel 2016 and earlier versions the SORTBY
function is not available.
Formula:
=SORTBY (A2:B10, B2:B10, -1)
Array is A2:A10 - since you do not wish the Value column to be displayed in the results, you
leave it out of the array.
By_array1 is B2:B10 - sort by Value.
Sort_order1 is -1 - descending, i.e. from highest to lowest.
Rank Function:
Returns the rank of a number in a list of numbers. The rank of a number is its size relative to other values
in a list. (If you were to sort the list, the rank of the number would be its position.)
KLESNC Rajajinagar
Syntax : RANK(number, ref, [order])
If order is 0 (zero) or omitted, Microsoft Excel ranks number as if ref were a list sorted in descending
order. If order is any nonzero value, Microsoft Excel ranks number as if ref were a list sorted in
ascending order.
Formula:
=Rank(A2,$A$2:$A$8,1)
=Rank(A2,$A$2:$A$8,0)
Data
7
3.5
3.5
1
2
Formula Description (Result) Result
=RANK(A3,A2:A6,1) Rank of 3.5 in the list above (3) 3
=RANK(A2,A2:A6,1) Rank of 7 in the list above (5) 5
KLESNC Rajajinagar
Lab Program 7
Argument Description
Required
include A Boolean array whose height or width is the same as the array
Required
[if_empty] The value to return if all values in the included array are empty (filter returns nothing)
Optional
Step1: In home tab click data in data dropdown select data validation.
Step2: Now data validation rules window will be open, once it opened add the rule
and Click Done.
KLESNC Rajajinagar
KLESNC Rajajinagar
Step 3: now use the filter function to filter the given data by using data validation.
Formula:
=filter (A2:D22,C2:C22=E1)
By using above formula it can filter the data by respective departments.
KLESNC Rajajinagar
FREQUENCY function :
The FREQUENCY function calculates how often values occur within a range of
values, and then returns a vertical array of numbers. For example, use
FREQUENCY to count the number of test scores that fall within ranges of scores.
Because FREQUENCY returns an array, it must be entered as an array formula.
Syntax :
FREQUENCY (data_array, bins_array)
The FREQUENCY function syntax has the following arguments:
data_array Required. An array of or reference to a set of values for which
you want to count frequencies. If data_array contains no values,
FREQUENCY returns an array of zeros.
bins_array Required. An array of or reference to intervals into which you
want to group the values in data_array. If bins_array contains no values,
FREQUENCY returns the number of elements in data_array.
KLESNC Rajajinagar
SEQUENCE Function:
In the following example, we created an array that's 4 rows tall by 5 columns wide
with =SEQUENCE (4,5).
=SEQUENCE(rows,[columns],[start],[step])
Argument Description
Required
KLESNC Rajajinagar
Argument Description
Optional
Optional
Optional
Formula: 1. =SEQUENCE(4,5)
2. =SEQUENCE(6,3)
3. =SEQUENCE(2,3,3,2)
KLESNC Rajajinagar
RANDARRAY function :
The RANDARRAY function returns an array of random numbers. You can specify the number of
rows and columns to fill, minimum and maximum values, and whether to return whole numbers
or decimal values.
Syntax :
=RANDARRAY([rows],[columns],[min],[max],[whole_number])
Argument Description
[rows] The number of rows to be returned
Optional
[columns] The number of columns to be returned
Optional
[min] The minimum number you would like returned
Optional
[max] The maximum number you would like returned
Optional
[whole_number] Return a whole number or a decimal value
KLESNC Rajajinagar
Formula:
RANDARRAY() // returns number like 0.098419132
IFERROR function:
You can use the IFERROR function to trap and handle errors in a formula. IFERROR returns a
value you specify if a formula evaluates to an error; otherwise, it returns the result of the
formula.
Syntax :
IFERROR(value, value_if_error)
KLESNC Rajajinagar
value_if_error Required. The value to return if the formula evaluates to an
error. The following error types are evaluated: #N/A, #VALUE!, #REF!,
#DIV/0!, #NUM!, #NAME?, or #NULL!.
Remarks :
If value or value_if_error is an empty cell, IFERROR treats it as an empty string value ("").
If value is an array formula, IFERROR returns an array of results for each cell in the range
specified in value. See the second example below.
Formula :
=IFERROR(A2/B2)
=IFERROR(A3/B3,"Value in error")
=IFERROR(A4/B4)
KLESNC Rajajinagar
Example 2
Quota Units Sold Ratio
210 35 6
55 0 Error in
calculation
23 0
Formula Description Result
=C2 Checks for an error in the formula in the first argument in the first element of 6
the array (A2/B2 or divide 210 by 35), finds no error, and then returns the
result of the formula
=C3 Checks for an error in the formula in the first argument in the second element Error in
of the array (A3/B3 or divide 55 by 0), finds a division by 0 error, and then calculation
returns value_if_error
=C4 Checks for an error in the formula in the first argument in the third element of 0
the array (A4/B4 or divide "" by 23), finds no error, and then returns the result
of the formula
Note: If you have a current version of Microsoft 365, then you can input the
formula in the top-left-cell of the output range, then press ENTER to confirm
the formula as a dynamic array formula. Otherwise, the formula must be
entered as a legacy array formula by first selecting the output range, input the
formula in the top-left-cell of the output range, then press
CTRL+SHIFT+ENTER to confirm it. Excel inserts curly brackets at the beginning
and end of the formula for you. For more information on array formulas,
see Guidelines and examples of array formulas.
KLESNC Rajajinagar
Lab Program – 7:
PIVOT TABLES, WHAT-IF ANALYSIS, DATA VALIDATION, SUBTOTALS
WITH RANGES
PIVOT TABLES:
A PivotTable is a powerful tool to calculate, summarize, and analyze data that lets
you see comparisons, patterns, and trends in your data. PivotTables work a little bit
differently depending on what platform you are using to run Excel.
KLESNC Rajajinagar
Step 2: Go to insert tab and Click on Pivot Table then it displays the dialogue box.
KLESNC Rajajinagar
WHAT-IF ANALYSIS :
KLESNC Rajajinagar
How to Use Goal Seek in Google Sheets :
o You will see the Goal Seek sidebar on the left of your spreadsheet, including
“Settings”, “Solve Status”, and “History”.
KLESNC Rajajinagar
o Click on the cell containing the profit formula, then click on the grid icon beside
“Set Cell” in the sidebar. If you place your cursor over the grid icon, you will see
the text “Capture selected cell”, as in the screenshot below.
o Next, type in the “Target value” for the “Set Cell”. Here, “20000”.
o Click on the cell containing the value you want Goal Seek to change, then click on
the grid icon beside “By Changing Cell” in the sidebar. Here, the selling price for
Scenario 1, cell B14.
o To change the number of iterations, the tolerance, and/or the time limit, click
on “Options”. Here, I will use the default values.
KLESNC Rajajinagar
o Once everything is ready, click “Solve.” With the default options used above, it
will take a maximum of two minutes to calculate the solution. If Goal Seek
cannot find a solution, try increasing the tolerance or the time limit and number
of iterations.
KLESNC Rajajinagar
SUBTOTALS WITH RANGES
Steps 1) Sort the data in descending order using sort option in Data tab. Sort
on region data.
2) Click on subtotal option from data tab→ select region in at each value
change field
KLESNC Rajajinagar
KLESNC Rajajinagar
Part-B: DA Programs:
1. Probability
Program -1:
# Simple probability
total_outcomes = 6
favorable_outcomes = 1 # Rolling a 4
output:
import random
num_trials = int(input("enter_no_of_trials"))
poss_outcomes=0
for i in range(num_trials):
for j in range(rolls_per_trial):
result = random.randint(1,6)
print(result)
if result == roll_up_value:
KLESNC Rajajinagar
poss_outcomes += 1
print("--------")
print("probability=",poss_outcomes / total_outcomes)
output:
KLESNC Rajajinagar
1. b) Applications of Probability distributions to real life problems
n = 10 # Number of trials
prob_2_success = binom.pmf(k_success, n, p)
output:
import pandas as pd
titanic_data = pd.read_csv('train.csv')
hypothetical_mean_age = 30
ttest_one_sample = stats.ttest_1samp(titanic_data['Age'].dropna(),
hypothetical_mean_age)
print("T-statistic:", ttest_one_sample.statistic)
print("p-value:", ttest_one_sample.pvalue)
KLESNC Rajajinagar
# Two Independent Samples T-Test: Comparing ages of male and female passengers
print("T-statistic:", ttest_two_ind_samples.statistic)
print("p-value:", ttest_two_ind_samples.pvalue)
before_fares = titanic_data['Fare'].dropna()
print("\nPaired T-Test:")
print("T-statistic:", ttest_paired.statistic)
print("p-value:", ttest_paired.pvalue)
titanic_data[titanic_data['Pclass'] == 2]['Fare'].dropna(),
titanic_data[titanic_data['Pclass'] == 3]['Fare'].dropna())
print("F-statistic:", anova_result.statistic)
print("p-value:", anova_result.pvalue)
KLESNC Rajajinagar
chi2_table = pd.crosstab(titanic_data['Survived'], titanic_data['Pclass'])
chi2_result = stats.chi2_contingency(chi2_table)
print("p-value:", chi2_result[1])
output:
T-statistic: -0.5534583115970276
p-value: 0.5801231230388639
T-statistic: 2.499206354920835
p-value: 0.012671296797013709
Paired T-Test:
T-statistic: -19.344277455944212
p-value: 7.255925461999272e-70
F-statistic: 242.34415651744814
p-value: 1.0313763209141171e-84
p-value: 4.549251711298793e-23
KLESNC Rajajinagar
program 3: Correlation and Regression analysis
Source Code:
import numpy as np
import pandas as pd
np.random.seed(42)
X = np.random.rand(100, 1) * 10
y = 2 * X.squeeze() + np.random.randn(100) * 2
plt.figure(figsize=(8, 4))
plt.scatter(X, y)
plt.title('Scatter Plot')
plt.xlabel('X')
KLESNC Rajajinagar
plt.ylabel('Y')
plt.grid(True)
random_state=42)
lin_reg = LinearRegression()
lin_reg.fit(X_train, y_train)
y_pred = lin_reg.predict(X_test)
r2 = r2_score(y_test, y_pred)
plt.figure(figsize=(8, 4))
plt.xlabel('X')
plt.ylabel('Y')
plt.grid(True)
KLESNC Rajajinagar
# Fitting logistic regression (using Iris dataset as an example)
iris = load_iris()
X_iris = iris.data[:, :2] # Using only the first two features for simplicity
y_iris = iris.target
log_reg = LogisticRegression()
log_reg.fit(X_iris, y_iris)
Z = log_reg.predict(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)
plt.figure(figsize=(8, 6))
plt.xlabel('Sepal Length')
plt.ylabel('Sepal Width')
plt.grid(True)
plt.show()
output:
KLESNC Rajajinagar
Mean Squared Error: 2.6147980548680088
KLESNC Rajajinagar
KLESNC Rajajinagar
Part- C: Power BI
1. Introduc�on to Power BI- Get Started with Power BI - Sign up for Power BI - Overview:
Power BI data sources - Connect to a SaaS solu�on - Upload a local CSV file - Connect to
Excel data that can be refreshed - Create a Report with Visualiza�ons
1.Introduc�on to Power BI
Power BI is a powerful business analy�cs tool developed by Microso� that enables users to visualize
and analyze data effec�vely, helping organiza�ons make data-driven decisions.
Power BI Desktop:
This is a free applica�on for Windows that allows users to create reports and data visualiza�ons. It
includes tools for data modelling, transforming data using Power Query, crea�ng rela�onships, and
designing interac�ve reports and dashboards.
KLESNC Rajajinagar
4. Overview : Power BI Data Sources:
Power BI supports various data sources, including but not limited to:
• SaaS Solu�ons: Connect to cloud-based services like Microso� Dynamics 365, Google Analy�cs,
Salesforce, etc.
• Local Files: Upload files from your computer, such as CSV, Excel, JSON, etc.
• Azure Services: U�lize Azure data services like Azure SQL Database, Azure Blob Storage, etc.
• Choose the type of SaaS solu�on you want to connect to (e.g., Salesforce, Google Analy�cs).
• Follow the prompts to sign in and connect to your SaaS solu�on. You'll likely need to provide
creden�als or permissions to access the data.
• Browse to locate and select the CSV file from your computer.
KLESNC Rajajinagar
7. Connect to Excel dthat can be refreshed:
KLESNC Rajajinagar
8. Create a Report with Visualiza�ons:
• Select the appropriate type of visualiza�on (e.g., bar chart, line chart, pie chart) from the
Visualiza�ons pane on the right-hand side.
• Drag and drop fields from your datasets onto the report canvas to create visualiza�ons such as
charts, graphs, tables, etc.
• Customize the visualiza�ons by forma�ng, sor�ng, and adding addi�onal elements like slicers,
text boxes, etc.
2. Using visualiza�ons - Create a new report - Create and arrange visualiza�ons - Format a
visualiza�on - Use text, map, and gauge visualiza�ons and save a report - Use a slicer to
filter visualiza�ons - Sort, copy, and paste visualiza�ons
KLESNC Rajajinagar
2. Create and Arrange Visualiza�ons:
• Select the appropriate type of visualiza�on (e.g., bar chart, line chart, pie chart) from the
Visualiza�ons pane on the right-hand side.
• Drag and drop fields from your dataset onto the visual to create different visualiza�ons like
bar charts, line graphs, etc.
• Arrange the visualiza�ons by clicking and dragging them to desired loca�ons on the canvas.
3. Format a Visualiza�on:
KLESNC Rajajinagar
4.Use text, map, and gauge visualiza�ons and save a report:
• Include a text visualiza�on by selec�ng "Card" from the "Visualiza�ons" pane and drag and drop
fields from your dataset onto the visual
• Add a map visualiza�on using the map visual from the visualiza�on pane and dragging a
geographical field onto the visual.
• Include a gauge visualiza�on by selec�ng "Gauge" from the "Visualiza�ons" pane and configuring
it with appropriate data.
• Click on "File" > "Save" to save the report in your desired loca�on and format.
KLESNC Rajajinagar
• Select “Slicer (new)” from the Visualiza�on pane and drag a field you want to use as a filter into
the slicer visual.
• Use the slicer to interac�vely filter the other visualiza�ons on the report by selec�ng specific
values.
• To sort visualiza�ons, select a visualiza�on and use the sort op�ons available in the "Format" or
"Visualiza�ons" pane.
• To copy and paste visualiza�ons, select the visualiza�on, right-click, and choose "Copy." Then,
right-click on the canvas and select "Paste."
3. Modify and Print a Report - Rename and delete report pages - Add a filter to a page or
report Set visualiza�on interac�ons - Send a report to PowerPoint
To modify a report in Power BI, you can edit exis�ng visuals, add new visuals, change forma�ng, and
adjust data connec�ons.
• Make the necessary modifica�ons to the visuals by edi�ng their proper�es, forma�ng, or data.
• To print the report, click on "File" and then select "Print" to configure the prin�ng se�ngs and
print the report.
• To rename a report page, right-click on the page name in the Pages pane, select "Rename," and
enter the new name.
• To delete a report page, right-click on the page name in the Pages pane and select "Delete."
KLESNC Rajajinagar
3. Add a Filter to a Page or Report:
• In Power BI Desktop, select the page or visual you want to apply the filter to.
• Choose the field you want to use as a filter and configure its se�ngs (e.g., filter type, values).
• Go to the "Format" pane (or right-click and select "Format") and navigate to the "Edit
interac�ons" op�on.
KLESNC Rajajinagar
• Adjust the interac�ons between visuals by selec�ng the interac�on type (e.g., highligh�ng,
filtering) for each visual.
• Configure the export se�ngs and click "Export" to generate the PowerPoint file with the report
visuals.
KLESNC Rajajinagar