Showing posts with label Microsoft. Show all posts
Showing posts with label Microsoft. Show all posts

Tuesday, June 30, 2015

Microsoft Excel: How to Round Dates to Current or Next Beginning of the Month

If you would like to unify the dates in Excel to be either in the beginning of current or next month, below formula is the solution.

Below example shows that Actual Date on 1/5/2014 (column A2) has a Controlled Date of 1/1/2014, because Jan-1st is less than 20th of the month, as specified in the formula. You can always change the threshold based on your needs.
Second record of Actual Date is 1/25/2014 (which is greater than 20th of the month), therefore, rounded up to the next month, as specified.

=IF(DAY(A2)<20,DATE(YEAR(A2),MONTH(A2),1),DATE(YEAR(A2),MONTH(A2)+1,1))


Monday, March 17, 2014

Microsoft Outlook: Auto Archive in Outlook 2010

Step 1: From the main screen of Outlook, Choose File/Options.

Step 2: From the Outlook Options screen, choose Advanced.

  

Step 3: From the Outlook Options screen, choose AutoArchive Settings button from the right hand pane.


Step 4: Configure the following key parameters: Run AutoArchive every and Clean out items older than. Note: Only select the button Apply these settings to all folders now if you want every folder on your mailbox to be set to auto archive. If you do not, you will need to set the auto archive configuration manually on each folder. Click OK

    

Step 5: From the Outlook Options screen, click OK.

  

Step 6: If any new folders are created after applying the default settings, modify the folder properties on the AutoArchive tab of the new folder. Select the radial button to the left of “Archive items in this folder using the default settings”, then click OK.


Microsoft Excel: How to select all objects (pictures and charts) easily in Excel?

Select all objects in active worksheet
You can apply the Go To command to select all objects easily. You can do it with following steps:
Step 1: Press the F5 key to open the Go To dialog box.
Step 2: Click the Special button at the bottom to open the Go To Special dialog box.
Step 3: In the Go To Special dialog box, check the Objects option.

Step 4: Click OK. Then it selects all kinds of objects in active worksheet, including all pictures, all charts, all shapes, and so on.

Select all pictures in active worksheet
It seems no easy way to select all pictures except manually selecting each one. Actually, VB macro can help you to select all pictures in active worksheet quickly.
Step 1: Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
Step 2: Click Insert > Module, and paste the following macro in the Module Window.

Public Sub SelectAllPics()
ActiveSheet.Pictures.Select
End Sub


Step 3: Press the F5 key to run this macro. Then it selects all pictures in active worksheet immediately.

Select all charts in active worksheet
VB macro can also help you to select all charts in active worksheet too.

Step 1: Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
Step 2: Click Insert > Module, and paste the following macro in the Module Window.

Public Sub SelectAllCharts()
ActiveSheet.ChartObjects.Select
End Sub


Step 3: Press the F5 key to run this macro. This macro will select all kinds of charts in active worksheet in a blink of eyes.

Friday, February 14, 2014

MS Excel: Repeating rows in Pivot Table

Repeat item labels in rows
  1. In the PivotTable report, click the row label that you want to repeat.
This displays the PivotTable Tools, adding an Options and a Design tab.
  1. On the Options tab, in the Active Field group, click Field Settings.
Excel Ribbon Image
 Tip    You can also right-click the row label that you want to repeat, and then click Field Settings.
  1. Click the Layout & Print tab, and then select the Repeat item labels check box.
 Tip    To remove the repeated labels, clear the Repeat item labels check box.
  1. To show the repeated labels in the PivotTable, make sure that Show item labels in tabular form is selected.
 Notes 
  • When you edit any of the repeated labels, the changes you make are automatically applied to all other cells with the same label.
  • When you change the format of all repeated labels by selecting the item label in the summary row or all repeated labels, the format is automatically applied to all other cells with the same label. However, you can also change the format of individual repeated labels without applying the same formatting to other cells with the same label.
  • Repeated labels are shown in tabular form only. They are not shown when compact form or outline form are applied.
Repeat item labels in columns
  1. In the PivotTable report, click the column label that you want to repeat.
This displays the PivotTable Tools, adding an Options and a Design tab.
  1. On the Options tab, in the Active Field group, click Field Settings.
Excel Ribbon Image
 Tip    You can also right-click the column label that you want to repeat, and then click Field Settings.
  1. Click the Layout & Print tab, and then select the Repeat item labels check box.
 Tip    To remove the repeated labels, clear the Repeat item labels check box.
 Notes 
  • When you edit any of the repeated labels, the changes you make are automatically applied to all other cells with the same label.
  • When you change the format of all repeated labels by selecting the item label in the summary row or all repeated labels, the format is automatically applied to all other cells with the same label. However, you can also change the format of individual repeated labels without applying the same formatting to other cells with the same label.
  • Repeated labels are shown in compact form for outer fields only. Repeated labels are not shown when outline form is applied.

Turn repeated item labels on or off for all fields
  1. Click anywhere in the PivotTable for which you want to repeat labels.
This displays the PivotTable Tools, adding an Options and a Design tab.
  1. On the Design tab, in the Layout group, click Report Layout.
Excel Ribbon Image
  1. Do one of the following:
  • To display repeated item labels, click Repeat All Item Labels.
  • To remove repeated item labels, click Do Not Repeat Item Labels.
  1. Click anywhere in the PivotTable for which you want to repeat labels (Test_O15).
  2. This displays the PivotTable Tools, adding an Options and a Design tab(Test_O15)

Friday, December 6, 2013

SQL: Top 10 SQL Query Tuning or SQL Optimization

SQL Tuning / SQL Optimization Techniques:

1) SQL query becomes faster if you use the actual columns names in SELECT statement instead of than '*'.
For Example: Write the query as
SELECT id, first_name, last_name, age, subject FROM student_details;
Instead of:
SELECT * FROM student_details; 

2) HAVING clause is used to filter the rows after all the rows are selected. It is just like a filter. Do not use HAVING clause for any other purposes.
For Example: Write the query as
SELECT subject, count(subject)
FROM student_details
WHERE subject != 'Science'
AND subject != 'Maths'
GROUP BY subject;

Instead of:
SELECT subject, count(subject)
FROM student_details
GROUP BY subject
HAVING subject!= 'Vancouver' AND subject!= 'Toronto';

3) Sometimes you may have more than one subqueries in your main query. Try to minimize the number of subquery block in your query.
For Example: Write the query as
SELECT name
FROM employee
WHERE (salary, age ) = (SELECT MAX (salary), MAX (age)
FROM employee_details)
AND dept = 'Electronics';

Instead of:
SELECT name
FROM employee
WHERE salary = (SELECT MAX(salary) FROM employee_details)
AND age = (SELECT MAX(age) FROM employee_details)
AND emp_dept = 'Electronics';

4) Use operator EXISTS, IN and table joins appropriately in your query.
   a) Usually IN has the slowest performance.
   b) IN is efficient when most of the filter criteria is in the sub-query.
   c) EXISTS is efficient when most of the filter criteria is in the main query.
For Example: Write the query as
Select * from product p
where EXISTS (select * from order_items o
where o.product_id = p.product_id)

Instead of:
Select * from product p
where product_id IN
(select product_id from order_items

5) Use EXISTS instead of DISTINCT when using joins which involves tables having one-to-many relationship.
For Example: Write the query as
SELECT d.dept_id, d.dept
FROM dept d
WHERE EXISTS ( SELECT 'X' FROM employee e WHERE e.dept = d.dept);

Instead of:
SELECT DISTINCT d.dept_id, d.dept
FROM dept d,employee e
WHERE e.dept = e.dept;

6) Try to use UNION ALL in place of UNION.
For Example: Write the query as
SELECT id, first_name
FROM student_details_class10
UNION ALL
SELECT id, first_name
FROM sports_team;

Instead of:
SELECT id, first_name, subject
FROM student_details_class10
UNION
SELECT id, first_name
FROM sports_team;

7) Be careful while using conditions in WHERE clause.
For Example: Write the query as
SELECT id, first_name, age FROM student_details WHERE age > 10;

Instead of:
SELECT id, first_name, age FROM student_details WHERE age != 10;

Write the query as
SELECT id, first_name, age
FROM student_details
WHERE first_name LIKE 'Chan%';

Instead of:
SELECT id, first_name, age
FROM student_details
WHERE SUBSTR(first_name,1,3) = 'Cha';

Write the query as
SELECT id, first_name, age
FROM student_details
WHERE first_name LIKE NVL ( :name, '%');

Instead of:
SELECT id, first_name, age
FROM student_details
WHERE first_name = NVL ( :name, first_name);

Write the query as
SELECT product_id, product_name
FROM product
WHERE unit_price BETWEEN MAX(unit_price) and MIN(unit_price)

Instead of:
SELECT product_id, product_name
FROM product
WHERE unit_price >= MAX(unit_price)
and unit_price <= MIN(unit_price)

Write the query as
SELECT id, name, salary
FROM employee
WHERE dept = 'Electronics'
AND location = 'Bangalore';

Instead of:
SELECT id, name, salary
FROM employee
WHERE dept || location= 'ElectronicsBangalore';

Use non-column expression on one side of the query because it will be processed earlier.

Write the query as
SELECT id, name, salary
FROM employee
WHERE salary < 25000;

Instead of:
SELECT id, name, salary
FROM employee
WHERE salary + 10000 < 35000;

Write the query as
SELECT id, first_name, age
FROM student_details
WHERE age > 10;

Instead of:
SELECT id, first_name, age
FROM student_details
WHERE age NOT = 10;

8) Use DECODE to avoid the scanning of same rows or joining the same table repetitively. DECODE can also be made used in place of GROUP BY or ORDER BY clause.
For Example: Write the query as
SELECT id FROM employee
WHERE name LIKE 'Ramesh%'
and location = 'Bangalore';

Instead of:
SELECT DECODE(location,'Bangalore',id,NULL) id FROM employee
WHERE name LIKE 'Ramesh%';

9) To store large binary objects, first place them in the file system and add the file path in the database.

10) To write queries which provide efficient performance follow the general SQL standard rules.
   a) Use single case for all SQL verbs
   b) Begin all SQL verbs on a new line
   c) Separate all words with a single space
   d) Right or left aligning verbs within the initial SQL verb

Source

Tuesday, November 12, 2013

SQL Server Date Formats

Standard Date Formats
Date Format
Standard
SQL Statement
Sample Output
Mon DD YYYY 1
HH:MIAM (or PM)
Default
SELECT CONVERT(VARCHAR(20), GETDATE(), 100)
Jan 1 2005 1:29PM 1
MM/DD/YY
USA
SELECT CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY]
11/23/98
MM/DD/YYYY
USA
SELECT CONVERT(VARCHAR(10), GETDATE(), 101) AS [MM/DD/YYYY]
11/23/1998
YY.MM.DD
ANSI
SELECT CONVERT(VARCHAR(8), GETDATE(), 2) AS [YY.MM.DD]
72.01.01
YYYY.MM.DD
ANSI
SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD]
1972.01.01
DD/MM/YY
British/French
SELECT CONVERT(VARCHAR(8), GETDATE(), 3) AS [DD/MM/YY]
19/02/72
DD/MM/YYYY
British/French
SELECT CONVERT(VARCHAR(10), GETDATE(), 103) AS [DD/MM/YYYY]
19/02/1972
DD.MM.YY
German
SELECT CONVERT(VARCHAR(8), GETDATE(), 4) AS [DD.MM.YY]
25.12.05
DD.MM.YYYY
German
SELECT CONVERT(VARCHAR(10), GETDATE(), 104) AS [DD.MM.YYYY]
25.12.2005
DD-MM-YY
Italian
SELECT CONVERT(VARCHAR(8), GETDATE(), 5) AS [DD-MM-YY]
24-01-98
DD-MM-YYYY
Italian
SELECT CONVERT(VARCHAR(10), GETDATE(), 105) AS [DD-MM-YYYY]
24-01-1998
DD Mon YY 1
-
SELECT CONVERT(VARCHAR(9), GETDATE(), 6) AS [DD MON YY]
04 Jul 06 1
DD Mon YYYY 1
-
SELECT CONVERT(VARCHAR(11), GETDATE(), 106) AS [DD MON YYYY]
04 Jul 2006 1
Mon DD, YY 1
-
SELECT CONVERT(VARCHAR(10), GETDATE(), 7) AS [Mon DD, YY]
Jan 24, 98 1
Mon DD, YYYY 1
-
SELECT CONVERT(VARCHAR(12), GETDATE(), 107) AS [Mon DD, YYYY]
Jan 24, 1998 1
HH:MM:SS
-
SELECT CONVERT(VARCHAR(8), GETDATE(), 108)
03:24:53
Mon DD YYYY HH:MI:SS:MMMAM (or PM) 1
Default +
milliseconds
SELECT CONVERT(VARCHAR(26), GETDATE(), 109)
Apr 28 2006 12:32:29:253PM 1
MM-DD-YY
USA
SELECT CONVERT(VARCHAR(8), GETDATE(), 10) AS [MM-DD-YY]
01-01-06
MM-DD-YYYY
USA
SELECT CONVERT(VARCHAR(10), GETDATE(), 110) AS [MM-DD-YYYY]
01-01-2006
YY/MM/DD
-
SELECT CONVERT(VARCHAR(8), GETDATE(), 11) AS [YY/MM/DD]
98/11/23
YYYY/MM/DD
-
SELECT CONVERT(VARCHAR(10), GETDATE(), 111) AS [YYYY/MM/DD]
1998/11/23
YYMMDD
ISO
SELECT CONVERT(VARCHAR(6), GETDATE(), 12) AS [YYMMDD]
980124
YYYYMMDD
ISO
SELECT CONVERT(VARCHAR(8), GETDATE(), 112) AS [YYYYMMDD]
19980124
DD Mon YYYY HH:MM:SS:MMM(24h) 1
Europe default + milliseconds
SELECT CONVERT(VARCHAR(24), GETDATE(), 113)
28 Apr 2006 00:34:55:190 1
HH:MI:SS:MMM(24H)
-
SELECT CONVERT(VARCHAR(12), GETDATE(), 114) AS [HH:MI:SS:MMM(24H)]
11:34:23:013
YYYY-MM-DD HH:MI:SS(24h)
ODBC Canonical
SELECT CONVERT(VARCHAR(19), GETDATE(), 120)
1972-01-01 13:42:24
YYYY-MM-DD HH:MI:SS.MMM(24h)
ODBC Canonical
(with milliseconds)
SELECT CONVERT(VARCHAR(23), GETDATE(), 121)
1972-02-19 06:35:24.489
YYYY-MM-DDTHH:MM:SS:MMM
ISO8601
SELECT CONVERT(VARCHAR(23), GETDATE(), 126)
1998-11-23T11:25:43:250
DD Mon YYYY HH:MI:SS:MMMAM 1
Kuwaiti
SELECT CONVERT(VARCHAR(26), GETDATE(), 130)
28 Apr 2006 12:39:32:429AM 1
DD/MM/YYYY HH:MI:SS:MMMAM
Kuwaiti
SELECT CONVERT(VARCHAR(25), GETDATE(), 131)
28/04/2006 12:39:32:429AM
Here are some more date formats that does not come standard in SQL Server as part of the CONVERT function.
Extended Date Formats
Date Format
SQL Statement
Sample Output
YY-MM-DD
SELECT SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 3, 8) AS [YY-MM-DD]
SELECT REPLACE(CONVERT(VARCHAR(8), GETDATE(), 11), '/', '-') AS [YY-MM-DD]
99-01-24
YYYY-MM-DD
SELECT CONVERT(VARCHAR(10), GETDATE(), 120) AS [YYYY-MM-DD]
SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 111), '/', '-') AS [YYYY-MM-DD]
1999-01-24
MM/YY
SELECT RIGHT(CONVERT(VARCHAR(8), GETDATE(), 3), 5) AS [MM/YY]
SELECT SUBSTRING(CONVERT(VARCHAR(8), GETDATE(), 3), 4, 5) AS [MM/YY]
08/99
MM/YYYY
SELECT RIGHT(CONVERT(VARCHAR(10), GETDATE(), 103), 7) AS [MM/YYYY]
12/2005
YY/MM
SELECT CONVERT(VARCHAR(5), GETDATE(), 11) AS [YY/MM]
99/08
YYYY/MM
SELECT CONVERT(VARCHAR(7), GETDATE(), 111) AS [YYYY/MM]
2005/12
Month DD, YYYY 1
SELECT DATENAME(MM, GETDATE()) + RIGHT(CONVERT(VARCHAR(12), GETDATE(), 107), 9) AS [Month DD, YYYY]
July 04, 2006 1
Mon YYYY 1
SELECT SUBSTRING(CONVERT(VARCHAR(11), GETDATE(), 113), 4, 8) AS [Mon YYYY]
Apr 2006 1
Month YYYY 1
SELECT DATENAME(MM, GETDATE()) + ' ' + CAST(YEAR(GETDATE()) AS VARCHAR(4)) AS [Month YYYY]
February 2006 1
DD Month 1
SELECT CAST(DAY(GETDATE()) AS VARCHAR(2)) + ' ' + DATENAME(MM, GETDATE()) AS [DD Month]
11 September 1
Month DD 1
SELECT DATENAME(MM, GETDATE()) + ' ' + CAST(DAY(GETDATE()) AS VARCHAR(2)) AS [Month DD]
September 11 1
DD Month YY 1
SELECT CAST(DAY(GETDATE()) AS VARCHAR(2)) + ' ' + DATENAME(MM, GETDATE()) + ' ' + RIGHT(CAST(YEAR(GETDATE()) AS VARCHAR(4)), 2) AS [DD Month YY]
19 February 72 1
DD Month YYYY 1
SELECT CAST(DAY(GETDATE()) AS VARCHAR(2)) + ' ' + DATENAME(MM, GETDATE()) + ' ' + CAST(YEAR(GETDATE()) AS VARCHAR(4)) AS [DD Month YYYY]
11 September 2002 1
MM-YY
SELECT RIGHT(CONVERT(VARCHAR(8), GETDATE(), 5), 5) AS [MM-YY]
SELECT SUBSTRING(CONVERT(VARCHAR(8), GETDATE(), 5), 4, 5) AS [MM-YY]
12/92
MM-YYYY
SELECT RIGHT(CONVERT(VARCHAR(10), GETDATE(), 105), 7) AS [MM-YYYY]
05-2006
YY-MM
SELECT RIGHT(CONVERT(VARCHAR(7), GETDATE(), 120), 5) AS [YY-MM]
SELECT SUBSTRING(CONVERT(VARCHAR(10), GETDATE(), 120), 3, 5) AS [YY-MM]
92/12
YYYY-MM
SELECT CONVERT(VARCHAR(7), GETDATE(), 120) AS [YYYY-MM]
2006-05
MMDDYY
SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 1), '/', '') AS [MMDDYY]
122506
MMDDYYYY
SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 101), '/', '') AS [MMDDYYYY]
12252006
DDMMYY
SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 3), '/', '') AS [DDMMYY]
240702
DDMMYYYY
SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 103), '/', '') AS [DDMMYYYY]
24072002
Mon-YY 1
SELECT REPLACE(RIGHT(CONVERT(VARCHAR(9), GETDATE(), 6), 6), ' ', '-') AS [Mon-YY]
Sep-02 1
Mon-YYYY 1
SELECT REPLACE(RIGHT(CONVERT(VARCHAR(11), GETDATE(), 106), 8), ' ', '-') AS [Mon-YYYY]
Sep-2002 1
DD-Mon-YY 1
SELECT REPLACE(CONVERT(VARCHAR(9), GETDATE(), 6), ' ', '-') AS [DD-Mon-YY]
25-Dec-05 1
DD-Mon-YYYY 1
SELECT REPLACE(CONVERT(VARCHAR(11), GETDATE(), 106), ' ', '-') AS [DD-Mon-YYYY]
25-Dec-2005 1
1 To make the month name in upper case, simply use the UPPER string function.

Tuesday, October 1, 2013

Business Intelligence Project Information Gathering Template

      Please note that this templates are created in MS OneNote.
      This template illustrates a basic technical information gathering for a new BI project.

      Contact
      File Transfer Process
      File Name
        1. John Doe
      Sample_File.csv

      Project/Metric Name
      Source File Name
      Data-Load Frequency
      Data-Load Type
      File Transfer Method
      Product Count
      SampleFile.csv
      Daily
      Full / Increment
      Upload

      • Database Table:
        • T_DIMENSION_TABLE_D
        • T_FACT_TABLE_F
      • Date Column:
        • ACTIVITY_DATE
          • Measures the metrics over certain period of time. i.e. MTD, QTD, YTD
      • Hierarchy / Drills:
        • Country > State > County > City > Zip Code
      • Filters:
        • Zip Code, First_Name, Last_Name etc...
      • Subject Area / Cube Name:
        • Sample Sales
      • Metrics:
        • A / B = C

      • Meeting Minutes:
        YYYY-MM-DD
        • Abc
        • Action item needs to be completed and colored into black
        YYYY-MM-DD
        • Abc

Business Intelligence Basic IT Infrastructure Template

    Please note that this templates are created in MS OneNote.
    This template is an overview of What you need to start a BI project.

    1. DOCUMENTATION:
      1. IT infrastructure
      1. Workflow process
      1. Data warehouse design - ER Diagram (ERD)
      1. On-going projects / new project initialization

    1. COMMUNICATION:

    Login:
    Password:
    Note:
    E-mail:
    username@doamin.com
    ***

    Chat Client:
    IM Chatter / username
    ***

    VPN:
    VPN Client / username
    ***


    1. SERVER ACCESS/NAME (Linux via Putty):
    Server Name
    Description
    Access Point
    User/Password
    n10:

    Server_name
    Username/Password

    1. BI ENVIRONMENT:

    URL
    Login
    Password
    Note
    DEV:

    Username
    Password

    SIT:

    Username
    Password

    STAGE:

    Username
    Password

    PROD:

    Username
    Password


    1. DATABASE CONNECTION (TNS):
    TNS Name / Environment:
    Schema User/Password
    Hostname
    Port
    Service Name
    TNS1
    Username/Password
    Host_name
    1234
    ORCL

    1. Other:
      1. Abc

Entity Relationship (ER) Diagram

How to read Entity Relationship (ER) diagram? and ER basics:

Sunday, May 12, 2013

Downgrading Internet Explorer to Previous Version

If you would like to remove Internet Explorer 9/10 update, follow below steps:

1. Close all programs, go to Start > Control Panel
2. Click Uninstall a Program under Programs category.
3. Click View installed updates option in the task pane.
4. Now select Windows Internet Explorer 9 or 10 shown under Microsoft Windows updates. 
5. Click Uninstall and follow the instructions on the screen.



6. After completing IE 9/10 uninstall Restart your PC and you are DONE!

Hope this helped!