Excel SQL Query - 202207 - v1.0 - W2D2
Excel SQL Query - 202207 - v1.0 - W2D2
• Formula
• None
• Function
• =NOW()
• Hands on
DAY
• Purpose
• Return the DAY of the month, for example if the date is 14 Feb 2014, DAY will
return the number 14 (as the 14th day of the month)
• Syntax
• DAY(serial_number)
• Hand On
MONTH
• Purpose
• Return the Month of the Year, for example if the date is 14 Feb 2014,
MONTH will return the 2 (as 2nd month of the year)
• Syntax
• MONTH(serial_number)
• Hand On
YEAR
• Purpose
• Return the Year, for example if the date is 14 Feb 2014, YEAR will return the
2014
• Syntax
• YEAR(serial_number)
• Hand On
DATE
• Purpose
• Can combine the (DAY, MONTH AND YEAR) function and return the date. The
previous 3 functions can disassemble a date and the DATE function can
reassemble a date
• Syntax
• DATE(year, month, day)
• Hand On
WEEKDAY
• Syntax
• WEEKDAY(serial_number,[return_type])
• Hand On
WEEKNUMBER
• Syntax
• WEEKNUM(serial_number,[return_type])
• Hand On
EDATE
• Purpose
• Returns the serial number that represents the date that is the indicated
number of months before or after a specified date (the start_date)
• Syntax
• =EDATE(start_date, months)
• Hands On
• Enter A2=15-Jan-11
• =EDATE(A2,1)
• =EDATE(A2,-1)
• Enter A2=Jan-23
• =EDATE(A2,1) and drag it to right to show output like below
• Exercise
• Calculate your age
• =YEAR(NOW()) – YEAR(Date of Birth)
DATA VALIDATION
• Purpose
• Use data validation to restrict the type of data or the values that users enter
into a cell, like a dropdown list.
• The data validation in Excel provides a way of limiting the mistakes from the
user and collecting valid data from the user. It results in standard data entry
and systematic reporting.
• Solution
• Select the cell(s) you want to create a rule for.
• Data Data Validation
• On the Settings tab, under Allow, select an option:
• Whole Number - to restrict the cell to accept only whole numbers.
• Decimal - to restrict the cell to accept only decimal numbers.
• List - to pick data from the drop-down list.
• Date - to restrict the cell to accept only date.
• Time - to restrict the cell to accept only time.
• Text Length - to restrict the length of the text.
• Custom – for custom formula
• On the Input Message tab, customize a message users will see when entering
data
• On the Error Alert tab, customize the error message. Now, if the user tries to
enter a value that is not valid, an Error Alert appears with your customized
message.
• Hands on
DROP DOWN LIST
• Purpose
• Allows you to create a drop down list in excel
• Solution
• Data Data Validation
• Hands on
FILTER
• Purpose
• Allows you to filter a range of data based on criteria you define
• Function
• =FILTER(array,include,[if_empty])
• Where
• array: The array, or range to filter
• include: A Boolean array whose height or width is the same as the
array
• [if_empty]: The value to return if all values in the included array are
empty (filter returns nothing)
• Hands on
• FILTER used to return multiple criteria
• =FILTER(A5:D20,(C5:C20=H1)*(A5:A20=H2),"").
• Filtering Columns
• FILTER is usually used for filtering rows
• It can also be used for filtering columns
• How? We input a horizontal array of 1s (TRUE) and 0s (FALSE) with the same
number of columns from the array input (1st argument)
• Columns that match with 0s are filtered out while columns that match with
1s are returned.
UNIQUE
• Purpose
• Returns a list of unique values in a list or range
• Function
• =UNIQUE(array)
• Where
• array: The array, or range to filter
• Hands on
• Full Name but Unique
• Compare 2 columns
REPT
• Purpose
• Repeats text a given number of times. Use REPT to fill a cell with a number of
instances of a text string.
• Syntax
• =REPT(text, number_times)
• Hands on
• Examples
SUBTOTAL
• Purpose
• Function that returns a subtotal in a range
• It can perform different arithmetic and logical operations such as counting cells, calculating
average, finding the minimum or maximum value, and more
• Function
• =SUBTOTAL(function_num, ref1, [ref2],…)
• Where
• Function_num - a number that specifies which function to use for the subtotal.
• Ref1, Ref2, … - one or more cells or ranges to subtotal. The first ref argument is
required, others (up to 254) are optional.
• The function_num argument can belong to one of the following sets
• 1 - 11 ignore filtered-out cells, but include manually hidden rows
• 101 - 111 ignore all hidden cells - filtered out and hidden manually.
• Why use Sub-total?
• Compared to the traditional Excel functions, SUBTOTAL gives you the following important
advantages.
• Calculate values in filtered rows
• If we filter the table, the Subtotal formula will automatically adjust
• Calculate only visible cells
• Subtotal formulas with function_num 101 to 111 ignore all hidden cells - filtered out
and hidden manually
• Ignore values in nested Subtotal formulas
• If the range supplied to your Excel Subtotal formula contains any other Subtotal
formulas, those nested subtotals will be ignored, so the same numbers won't be
calculated twice
• Problem
• If the Subtotals command is grayed out, that’s because subtotals can’t be added to tables.
But there’s a quick way around this. Convert your table to a range of data. Then you can add
subtotals.
• Solution
• Right-click a cell in your table, point to Table, and then click Convert to Range.
Any Questions?
Thank you