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:
Step-by-Step Guide to Data Entry & Formatting (11:00)
https://www.youtube.com/watch?v=DyG6Gc8nOAEMicrosoft Excel for Beginners - Learn the Basics (30:35)
https://www.youtube.com/watch?v=BV9EduuuXO4Excel 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:
- Open your Superstore Sales dataset in Excel (from Day 1)
- Make sure you have columns: OrderID, Product, Category, Region, Sales, Quantity, Discount, Profit
- Ensure row 1 has column headers
- Save as "Day03_Practice.xlsx"
Exercise 1: Apply AutoFilter to Find Specific Data
Step-by-Step Instructions:
- Click on any cell in your data (e.g., A1)
- Go to Data tab β Click Filter button
- Notice dropdown arrows appear in each column header
- Filter by Region:
- Click the dropdown arrow in the "Region" column
- Uncheck "Select All"
- Check only "West"
- Click OK
- You should now see only West region orders!
- Add another filter: In the "Category" dropdown, select only "Technology"
- Now you see only West region + Technology category orders
- 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:
- Add a new column header "Performance" in column J (or next empty column)
- Click on cell J2 (first data row)
- Type this formula:
=IF(I2>0, "Profit", "Loss")(assuming Profit is in column I) - Press Enter
- Copy the formula down to all rows (double-click the fill handle)
- 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:
- Find an empty area in your spreadsheet (e.g., cell L2)
- Type a label "Orders > $500:" in K2
- In L2, type:
=COUNTIF(D:D, ">500")(assuming Sales in column D) - 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:
- In cell L4, type label "Total West Sales:" in K4
- 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)
- 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:
- In cell L6, type label "Avg Profit (Profitable Orders):" in K6
- 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
- Press Enter
- 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
- Create profit status: IF profit<0, βLossβ, else βProfitβ
- Count customers from California
- Sum quantities where product is βChairsβ
- Nested IF for discount tiers: >20%=βHighβ, >10%=βMedβ, else=βLowβ
- Average sales for orders with quantity>10
- Count orders in Q4 (October-December)
- Sum profits for profitable orders only (Profit>0)
- Use IFS to categorize: Sales>5000=βAβ, >2000=βBβ, else=βCβ
Daily Assignment (60 min):
- Create customer segmentation: Large (>10 orders), Medium (5-10), Small (<5)
- Build profitability dashboard showing counts by profit status
- Save as: Day03_Excel_Practice.xlsx
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?