Data Cleaning and Visualization
Data Cleaning and Visualization
Function Purpose
IF Performs conditional checks and returns one value if TRUE and
another if FALSE.
AND
Checks if all conditions are TRUE.
OR Checks if any condition is TRUE.
NOT Reverses the logical result of a condition.
IFS Evaluates multiple conditions and returns corresponding values (Excel-
specific).
1. IF Function
Returns one value if a condition is TRUE and another value if it is FALSE.
• Syntax: =IF(logical_test, value_if_true, value_if_false)
• Example:
Suppose we have a score in cell A1, and we want to determine Pass or Fail based on
whether the score is greater than or equal to 50.
Formula:
=IF(A1>=50, "Pass", "Fail")
Output:
o If A1 = 70 → Result is "Pass".
o If A1 = 40 → Result is "Fail".
2. AND Function
Returns TRUE if all conditions are TRUE.
• Syntax: =AND(condition1, condition2, ...)
• Example:
Check if a student passed both Math (A1) and Science (B1) with scores ≥50.
Formula:
=AND(A1>=50, B1>=50)
3. OR Function
Returns TRUE if at least one condition is TRUE
• Syntax: =OR(condition1, condition2, ...)
• Example:
Check if a student passed either Math (A1) or Science (B1) with scores ≥50.
Formula:
=OR(A1>=50, B1>=50)
Output:
o If A1 = 60 and B1 = 40 → Result is TRUE.
o If A1 = 40 and B1 = 30 → Result is FALSE.
4. NOT Function
Reverses the result of a condition.
• Syntax: =NOT(logical_test)
• Example:
Check if an item is not "Out of Stock" (A1).
Formula:
=NOT(A1="Out of Stock")
Output:
o If A1 = "In Stock" → Result is TRUE.
o If A1 = "Out of Stock" → Result is FALSE.
6. IFERROR Function
Returns a custom value if a formula results in an error; otherwise, returns the formula’s
result.
• Syntax: =IFERROR(formula, value_if_error)
• Example:
Handle errors when dividing numbers (A1/B1).
Formula:
=IFERROR(A1/B1, "Error")
Output:
o If A1 = 10, B1 = 2 → Result is 5.
o If A1 = 10, B1 = 0 → Result is "Error".
7. SWITCH Function
Evaluates an expression against a list of values and returns the corresponding result
for the first match. If no match is found, returns a default value.
• Syntax: =SWITCH(expression, value1, result1, [value2, result2], ..., [default])
• Example:
o Formula: =SWITCH(A1, "Red", 1, "Blue", 2, "Green", 3, 0)
o Description: Returns 1 if A1 is "Red", 2 if "Blue", 3 if "Green", and 0
otherwise.
1. VLOOKUP Function
Searches for a value in the first column of a table and returns a value in the same row from a
specified column.
• Syntax:
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
Parameters:
1. lookup_value: The value you want to look up.
2. table_array: The range of cells that contains the data.
3. col_index_num: The column number in the table array from which to retrieve the
value.
4. [range_lookup]: Optional. TRUE for an approximate match or FALSE for an exact
match.
2. HLOOKUP Function
Searches for a value in the first row of a table and returns a value in the same column from a
specified row.
• Syntax:
=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
Parameters:
1. lookup_value: The value you want to search for in the first row.
2. table_array: The range of cells containing the data, including the row where you
want to search and retrieve the value.
3. row_index_num: The row number (relative to the table_array) from which to return
the result.
Ms. Aleena Rose, Sacred Heart College (Autonomous), Chalakudy
4. [range_lookup] (optional):
o TRUE: Approximate match (default if omitted).
o FALSE: Exact match
Example: Find the Department (in the 3rd row) of the employee with ID 102.
ID 101 102 103
Name Alice Bob Charlie
Dept. HR IT Finance
3. INDEX Function
Returns the value of a cell within a specified range based on row and column numbers.
• Syntax:
=INDEX(array, row_num, [column_num])
Parameters:
o array: The range of data.
o row_num: The row number in the range.
o column_num: The column number in the range.
Example: Retrieve the Department of the 3rd row.
ID Name Department
101 Alice HR
102 Bob IT
103 Charlie Finance
104 Diana Marketing
=INDEX(A1:C5, 3, 3)
Result: Finance
4. MATCH Function
Purpose: Returns the position of a value in a range.
• Syntax:
=MATCH(lookup_value, lookup_array, [match_type])
o lookup_value: The value you want to find.
o lookup_array: The range to search.
o match_type: 1 for less than, 0 for exact match, -1 for greater than.
Example: Find the position of "Charlie" in the list.
Name
Alice
Bob
Charlie
=MATCH("Charlie", A1:A4, 0)
Result: 3 (Charlie is in the 3rd row)
Financial functions
Financial functions like NPV, IRR, and PMT are essential for analyzing financial data and
making decisions in spreadsheet tools such as Microsoft Excel, Google Sheets, or other
similar applications.
3. PMT (Payment)
What is PMT?
PMT calculates the regular payment for a loan or investment based on constant payments
and a fixed interest rate. It's typically used for loan payments, mortgage payments, or
regular investments.
In simple words, PMT answers: "How much do I need to pay each period to repay a loan
or investment?"
Syntax: =PMT(rate, nper, pv, [fv], [type])
• rate: The interest rate per period (e.g., 5% annually, but if payments are monthly,
divide by 12).
• nper: The total number of periods (e.g., 12 months, 5 years).
• pv: The present value, or the loan amount (or investment amount).
• [fv]: The future value (optional, usually 0 if paying off the loan completely).
• [type]: When the payments are due. Use 0 for the end of the period (default) and 1 for
the beginning.
Array formulas
1. SUMPRODUCT
Syntax: =SUMPRODUCT(array1, [array2], [array3], ...)
Explanation: The SUMPRODUCT function multiplies the corresponding elements in the
provided arrays (or ranges) and then adds them up. It’s typically used for weighted averages
or conditional calculations.
Example:
A B
Quantity Price
2 5
3 6
4 7
5 8
A B
Product Sales
Apple 5
Banana 3
Apple 4
Orange 6
A B
Product Sales
Apple 5
Banana 3
Apple 4
Orange 6
Formula: =TRANSPOSE(A1:A4)
This transposes the column values into a row:
• 1, 2, 3, 4 in a single row.
5. ARRAY MULTIPLICATION
Syntax: =array1 * array2
Explanation: You can multiply two arrays (ranges) element-wise in Excel or Google Sheets.
This operation is done for each corresponding pair of values.
Example:
A B
Quantity Price
2 5
3 6
4 7
5 8
A B
Product Price
Apple 4
Banana 6
Orange 8
Grape 3
Text to Columns
Splitting full names into first and last names
• Scenario: You have a list of customer full names, and you want to split them into first
and last names.
Select the "Full Name" column.
Go to the Data tab and click Text to Columns.
In the wizard, choose Delimited and click Next.
Choose Space as the delimiter and click Finish.
The names will be split into separate columns
Error Checking
Excel has built-in tools for detecting and managing errors in your data:
• Error Indicators: Excel highlights cells with errors (like #VALUE!, #DIV/0!, etc.).
You can click on the small warning icon next to a cell to get more information about
the error and potential fixes.
• IFERROR: This function helps manage errors by allowing you to specify a custom
result if a formula returns an error.
• ISERROR, ISNA, ISBLANK: These functions help detect specific types of errors:
o =ISERROR(A1) returns TRUE if A1 contains any error.
o =ISNA(A1) returns TRUE if A1 contains an #N/A error.
o =ISBLANK(A1) returns TRUE if A1 is empty.