DAY 3: Excel - Filtering & Conditional Functions

Guru Charan Pathalla

DAY 3: Excel - Filtering & Conditional Functions

Learning Objectives: - Master AutoFilter and Advanced Filter - Use IF, IFS, and nested IF functions - Learn COUNTIF, SUMIF, AVERAGEIF - Apply conditional logic in formulas

Topics Covered (60 min):

1. Data Filtering - AutoFilter: Quick column filtering - Advanced Filter: Complex multi-criteria - Filter by values, text, numbers, dates - Clear filters, filter multiple columns

2. IF Function - Syntax: =IF(condition, value_if_true, value_if_false) - Example: =IF(A1>100, "High", "Low") - Nested: =IF(A1>100, "High", IF(A1>50, "Med", "Low")) - IFS (2019+): =IFS(A1>100, "High", A1>50, "Med", TRUE, "Low")

3. Conditional Aggregates - =COUNTIF(range, criteria) - Count cells meeting condition - =SUMIF(range, criteria, sum_range) - Sum with condition - =AVERAGEIF(range, criteria, avg_range) - Average with condition - Example: =SUMIF(B:B, ">100", C:C) - Sum C where B>100

4. Multiple Criteria - =SUMIFS(sum_range, criteria_range1, criteria1, criteria_range2, criteria2) - Can add many criteria pairs

Video Resources:

  1. Step-by-Step Guide to Data Entry & Formatting (11:00)
    https://www.youtube.com/watch?v=DyG6Gc8nOAE

  2. Microsoft Excel for Beginners - Learn the Basics (30:35)
    https://www.youtube.com/watch?v=BV9EduuuXO4

  3. Excel Tutorial for Beginners (15:26)
    https://www.youtube.com/watch?v=LgXzzu68j7M

AI Learning Prompts (Concept Understanding Only):

Understanding IF Functions:

Explain Excel IF functions for conditional logic:

1. What is the syntax of the IF function?
2. How do I read the logic: IF(condition, value_if_true, value_if_false)?
3. What's the difference between IF, IFS, and nested IF?
4. When should I use each type?
5. Show me examples using student grades (if score >=60, "Pass", else "Fail")
6. How many levels can I nest IF statements?

Provide clear examples using grades or temperature data (not sales).

Understanding Conditional Aggregates:

Explain conditional aggregate functions in Excel:

1. What's the syntax for SUMIF, COUNTIF, and AVERAGEIF?
2. How do they differ from regular SUM, COUNT, AVERAGE?
3. What types of criteria can I use (numbers, text, dates)?
4. How do I use comparison operators (>, <, >=, <=, <>)?
5. Show examples using library book data (count books by genre, sum pages for fiction, etc.)
6. What's the difference between SUMIF and SUMIFS?

Use examples with book inventory or student records (not sales data).

Understanding Multiple Criteria:

Explain how to handle multiple conditions in Excel:

1. How do SUMIFS, COUNTIFS, AVERAGEIFS work?
2. What's the syntax difference from single-criteria functions?
3. Can I mix AND/OR logic?
4. Show me examples using employee data (count employees by department AND salary range)
5. How many criteria can I use?

Provide examples using HR data or school records.

Guided Practice (60 min):

πŸ“ How to approach Guided Practice:

  • Follow step-by-step: Work through each exercise in order
  • Use provided resources: Reference the video tutorials and AI prompts if you get stuck
  • Verify your work: Check your results match expected outcomes
  • Take notes: Document key learnings and shortcuts you discover
  • Ask for help: Use AI assistants to clarify concepts you don't understand

Using Superstore Sales dataset - Excel Practice

πŸ“ Setup Instructions:

  1. Open your Superstore Sales dataset in Excel (from Day 1)
  2. Make sure you have columns: OrderID, Product, Category, Region, Sales, Quantity, Discount, Profit
  3. Ensure row 1 has column headers
  4. Save as "Day03_Practice.xlsx"

Exercise 1: Apply AutoFilter to Find Specific Data

Step-by-Step Instructions:

  1. Click on any cell in your data (e.g., A1)
  2. Go to Data tab β†’ Click Filter button
  3. Notice dropdown arrows appear in each column header
  4. Filter by Region:
    • Click the dropdown arrow in the "Region" column
    • Uncheck "Select All"
    • Check only "West"
    • Click OK
  5. You should now see only West region orders!
  6. Add another filter: In the "Category" dropdown, select only "Technology"
  7. Now you see only West region + Technology category orders
  8. Clear filters: Data tab β†’ Click "Clear" button

πŸ’‘ Tips:

  • Keyboard shortcut for Filter: Ctrl + Shift + L
  • Filtered rows show blue row numbers
  • Status bar shows "X of Y records found"
  • You can filter multiple columns simultaneously

βœ… Expected Result: Data filtered to show only rows matching your criteria

πŸ”„ SQL Equivalent: See how filtering works in SQL!

Exercise 2: Use IF Function for Conditional Logic

Step-by-Step Instructions:

  1. Add a new column header "Performance" in column J (or next empty column)
  2. Click on cell J2 (first data row)
  3. Type this formula: =IF(I2>0, "Profit", "Loss") (assuming Profit is in column I)
  4. Press Enter
  5. Copy the formula down to all rows (double-click the fill handle)
  6. You should see "Profit" for positive values, "Loss" for negative

Now try a nested IF for 3 categories:

=IF(I2>500, "High Profit", IF(I2>0, "Low Profit", "Loss"))

πŸ” Understanding the Formula:

  • IF(condition, value_if_true, value_if_false)
  • First checks: Is profit > 500? If yes β†’ "High Profit"
  • If no, checks: Is profit > 0? If yes β†’ "Low Profit"
  • If both false β†’ "Loss"

πŸ’‘ Tips:

  • Always close your parentheses - Excel will help highlight matching pairs
  • Use nested IFs when you have 2-3 conditions; use IFS() for more (Excel 2019+)
  • Test with both TRUE and FALSE scenarios

βœ… Expected Result: A new column with text labels based on profit values

πŸ”„ SQL Equivalent: See how conditional logic works in SQL!

Exercise 3: COUNTIF - Count Cells Meeting a Condition

Step-by-Step Instructions:

  1. Find an empty area in your spreadsheet (e.g., cell L2)
  2. Type a label "Orders > $500:" in K2
  3. In L2, type: =COUNTIF(D:D, ">500") (assuming Sales in column D)
  4. Press Enter - this counts how many sales exceed $500

Try these variations:

  • Count West region orders: =COUNTIF(C:C, "West") (if Region is column C)
  • Count discounted orders: =COUNTIF(F:F, ">0") (if Discount is column F)
  • Count specific products: =COUNTIF(B:B, "Staples") (if Product is column B)

πŸ’‘ Tips:

  • Criteria with operators (>, <, =) must be in quotes: ">100"
  • Text criteria need quotes: "West"
  • You can reference a cell: =COUNTIF(C:C, K5) counts values equal to K5

βœ… Expected Result: A count of cells matching your condition

πŸ”„ SQL Equivalent: See how counting with conditions works in SQL!

Exercise 4: SUMIF - Sum Values Meeting a Condition

Step-by-Step Instructions:

  1. In cell L4, type label "Total West Sales:" in K4
  2. Type this formula: =SUMIF(C:C, "West", D:D)
    • C:C = Range to check (Region column)
    • "West" = Condition to match
    • D:D = Range to sum (Sales column)
  3. Press Enter - shows total sales for West region only

Try these examples:

  • Sum profits where sales > 1000: =SUMIF(D:D, ">1000", I:I)
  • Sum sales for Technology category: =SUMIF(E:E, "Technology", D:D)
  • Sum quantity for discounted orders: =SUMIF(F:F, ">0", G:G)

πŸ’‘ Tips:

  • SUMIF syntax: =SUMIF(range_to_check, criteria, sum_range)
  • If sum_range is omitted, it sums the range_to_check
  • Use absolute references ($C$2:$C$100) if you plan to copy the formula

βœ… Expected Result: Sum of values where condition is TRUE

πŸ”„ SQL Equivalent: See how conditional summing works in SQL!

Exercise 5: AVERAGEIF - Average Values Meeting a Condition

Step-by-Step Instructions:

  1. In cell L6, type label "Avg Profit (Profitable Orders):" in K6
  2. Type formula: =AVERAGEIF(I:I, ">0", I:I)
    • This calculates average of only positive profits
    • First I:I = range to check
    • ">0" = condition (greater than zero)
    • Second I:I = range to average
  3. Press Enter
  4. Compare this to a simple =AVERAGE(I:I) - notice the difference!

More examples:

  • Average sales for East region: =AVERAGEIF(C:C, "East", D:D)
  • Average quantity for high-value orders: =AVERAGEIF(D:D, ">1000", G:G)

πŸ’‘ Tips:

  • AVERAGEIF ignores cells that don't meet the criteria (different from simple AVERAGE)
  • Great for calculating averages excluding outliers or specific categories
  • Format result as currency/number as appropriate

βœ… Expected Result: Average of only the values meeting your condition

πŸ”„ SQL Equivalent: See how conditional averaging works in SQL!

🎯 Practice Goal Checkpoint:

By completing these 5 exercises, you should now be able to:

  • Use AutoFilter to quickly filter data by multiple criteria
  • Write IF functions for conditional logic (including nested IFs)
  • Use COUNTIF to count cells meeting specific conditions
  • Use SUMIF to sum values based on criteria
  • Use AVERAGEIF to calculate conditional averages
  • Understand the difference between regular and conditional functions

Key Insight: Conditional functions let you analyze subsets of your data without actually filtering it visually!

Take a 5-minute break, then move on to Independent Practice!

Independent Practice (60 min):

πŸ’‘ Hints for Independent Practice:

  • Start simple: Begin with basic variations before attempting complex modifications
  • Break it down: Divide complex problems into smaller, manageable steps
  • Test incrementally: Verify each step works before moving to the next
  • Use documentation: Refer to official docs or tutorials when needed
  • Experiment: Try different approaches to find what works best
  1. Create profit status: IF profit<0, β€œLoss”, else β€œProfit”
  2. Count customers from California
  3. Sum quantities where product is β€œChairs”
  4. Nested IF for discount tiers: >20%=β€œHigh”, >10%=β€œMed”, else=β€œLow”
  5. Average sales for orders with quantity>10
  6. Count orders in Q4 (October-December)
  7. Sum profits for profitable orders only (Profit>0)
  8. Use IFS to categorize: Sales>5000=β€œA”, >2000=β€œB”, else=β€œC”

Daily Assignment (60 min):

Expected Outcomes:

βœ“ Filter data effectively using AutoFilter
βœ“ Apply conditional logic with IF functions
βœ“ Use conditional aggregates for analysis
βœ“ Submit: Day03_Excel_Practice.xlsx


πŸ“ Day 3 Quick Quiz - Test Your Knowledge!

Q1. What is the correct syntax order for the IF function?

Q2. How many conditions can a single IF function evaluate?

Q3. What's the main advantage of IFS over nested IFs?

Q4. What happens if all IFS conditions are FALSE and no default is provided?

Q5. What does =IF(A1>=60,"Pass","Fail") return when A1=75?

Have feedback or questions?