Sunday, 18 September 2016

Data Blending


Data Blending

We use the Data Blending process when data is located into multiple databases. It is Horizontal merging it means Data bases are having different columns apart from common column for define the relationship.
Example:
The following example illustrates, how to use the two data sources to build the Report.




1) Connect the Tableau with "ABC" database, Then connect to Database "XYZA" by clicking on "Connect to database"




2) Once we connected to database 2, we have to define the relationship between 2 databases. Here Column "A" is common to define the Relationship. 3) Click on Data on menu bar, Click on "Edit Relationship", Then Select Primary & secondary databases then define the relationship between those 2 databases. 
Now we can use 2 databases to build  the reports.Once we define the Relationship between 2 databases, Primary Database will be highlighted in BlueSecondary in Orange color.
 If relationship will be removed, then we get the nulls when use columns.
from 2 databases.
=====================================
Data Blending: connect to Multiple DB (Columns Level Mapping, Column level Merging)

How to connect to Multiple DB 
 Either Homogeneous : Same kind of DB like Sales (Oracle), Orders (Oracle)  

or Heterogeneous : Different Kind of Databases Like Sales (Oracle), Orders (XL)...... 
)

1) Sales to Profits

2) Sales to Orders


Blue - Primary
Orange - Secondary

DB1
CNT Sales

DB2
CNT Orders

Data Blending:(Column Level Merging)
CNT, Sales, Orders

DB3
CNT Profits

1) CNT Sales, Orders Profits (Horizontal Merging, It is Right Approach) : Data Blending

2) CNT  Sales ( It is not Right Approach)
        Orders
        Profits

Monday, 5 September 2016

String Functions

1) ASCII:
It returns first letter of String's ASCII
ASCII(“Tableau”) =  84

2) Char: 
This function converts numerical number in to character.
EX: char(65)= A

3) Contains:
It will check whether substring is available or not in the main string.
It means it gives the Outputs as True/False
EX: 
Region = South
contains([Region], "st") = True
contains([Region], "k") = False

4) ENDWITH:
It will check whether substring is endswith or not in the main string.
It means it gives the Outputs as True/False

EX:ENDSWITH( [Region], 'st' )
Region = South
endwith([Region], "th") = True
endwith([Region], "k") = False

5) Find:
It will check the position of substring in the main string.
It means it gives the Outputs as Numerical Numbers.
Region = South
Find ([Region], "th") = True
Find ([Region], "k") = False

6) Findnth:
This function verifies the string & gives specified substring position 
for nth occurrence.
Findnth(“developer”,1,’e’)

Findnth(“developer”,’e’,1) = 2
Findnth(“developer”,’e’,2) = 4
Findnth(“developer”,’pe’,2) = 7

7) Isdate:
This is used to test the given string data, 
if given data is date then returns “True” else false.
EX: isdate(‘[Order_Date]’) =  True
Isdate(’12-Feb-2011’) = True

8) LEFT:
We use this function to fetch substring from starting point to 
specific point in the given Main String.
EX: Left([Customer Name],3)
Region = South
Left([Region],2) = So

9) LEN: 
This function count the number of characters including nulls & returns Numerical number.

10) MAX:
Test & returns Maximum as output.
Max(“A”, “B”)= B
Max(“AAAA”, “D”)= D

11) Min:
This function checks it gives minimum number as output as per 
first character’s ASCII value.
EX: Min ('A', 'B') = A

12) MID:
This function is used to extract the sub string from specific point 
to specific point.
EX: Region = South
Mid( [Region], 2,4) = out

13) Replace:
This function is used to replace the substring by other substring.
EX: replace([Region], “th”, “th Carolina”) = South Carolina

14) Right:
This function fetch the data up to specified number of positions 
from right side.
15) RTRIM:
This function removes empty space after the word, 
which means right side empty space.

16) Space:
This function is used to add the space in the word & 
defined number of times.

17) Stars with:
This function test whether string stars with specified substring, & 
returns Boolean.

18) Trim:
This function removes extra space of string for left & 
right edges of the given string.

19) Upper: It converts the given string into Upper Case.


Friday, 2 September 2016

Dual Axis:

Dual Axis:

Showing 1 Measure values on top on another Measure Values, it means override the Measure Values.
Main Usage is comparing two KPI's for any Dimension.


EX: BUZ User Wants to see Sales, Profits of Regions in the Single Report.

1) Drag the Regions on to Rows shelf, Sales & Profit fields onto Columns Shelf.
2) To differentiate measures, apply different colors for both Measures.
3) Right click on Second measure in the work Area, then click on "Dual Axis".
4) Now Report will show two measure values in single pane.
Have to Keep 1st Max Value KPI then Less Value KPI.

Synchronize Axis:
To follow the Same Scale for both Measures.

CASCADING FILTER.


We use the show Relevant values to view associated values in quick filter, we can say it is CASCADING FILTER.

It means, State Quick Filter is showing Values as per values selected in "Region" quick filter.






Date Functions


Tableau supports the following Date formats.
Tableau Supported the following parts of the Date.


DATE_PART VALUES

'year'  Four-digit year

'quarter' 1-4

'month' 1-12 or "January", "February", and so on

'dayofyear' Day of the year; Jan 1 is 1, Feb 1 is 32, and so on


'day'  1-31

'weekday' 1-7 or "Sunday", "Monday", and so on

'week'  1-52

'hour'  0-23

'minute' 0-59

'second' 0-60


Dateadd:
We use this function to perform Date Calculations
Like addition or subtraction at different levels.
Levels: Year, Quarter, Month,.........

EX: dateadd('month', 2, #12-Jan-2014#)
O/P: 12-Mar-2014

****************************
Datediff:

We use this function to find the difference between two DATES in terms of specified date parts like Year, Month, Date and it gives the O/P in integers.
Once created the Calculated field, drag that into Dimension window.

EX:DATEDIFF('day',[Order Date],[Ship Date] )


****************************
Datename
We use this function to extract specific part of the Date, It gives O/P as string Date Type.

EX:

1) datename('year', #12-Jan-2014#)
O/P: 2014

2) datename('month', #12-Jan-2014#)
O/P: Jan

3) datename('weekday',  #12-Jan-2014#)
O/P: Sunday


****************************
DATEPARSE:
Converts a string to a datetime in the specified format.

EX:
DATEPARSE ("dd.MMMM.yyyy", "15.April.2014") = #April 15, 2014#
DATEPARSE ("h'h' m'm' s's'", "10h 5m 3s") = #10:05:03#
****************************
Datetrunc
We use this function to get the First Date of given Date at Defined Level. (Opening Date)

EX:
1) Datetrunc('year', #12- Feb-2014#)
O/P: 1-Jan-2014
2)  Datetrunc('month', #12- Feb-2014#)
O/P: 1-Feb-2014

****************************
Day, Month, Year:

-> We use these functions to extracts the Specific part from the Date, It means Year, Day, Month. And it gives Integer as Output.

-> Once you created calculated field using any of these functions, that will be moved into Measures window since this function gives O/P in Number Data type.
EX:
1) day(#12-Jan-2014#)
O/P: 12

2) month(#12-Jan-2014#)
O/P:1

3) year(#12-Jan-2014#)
O/P:2014


Defining Starting Month of Year(Defining Fiscal Year)



Generally Calendar Years starts with Jan Month, Indian Fiscal year starts with Mar Month.

The following example explains how to get the Indian Fiscal Calendar.

-> Right click on "database", click on Date Properties, click on "Fiscal Year Start"
then define starting month of the year.



Quick Filters

Quick Filters:

-> We use the Quick Filters to include or exclude the members from the report.

-> It offers more interaction with report,It means End user can select required data instantly.
If user don't want to see the data on the report, then they can deselect that specific member from Quick Filter.

EX:
1) Drag [Region], [Order Date], [Customer Name] fields into Rows shelf.

2) Drag the one of Measure fields from Measures window into Column Shelf.

3) Right click on  [Region] in the work area then click on Show "Quick Filter".


Changing the UI:

1) Single Value (List):  This option offers select only 1 member at a time or select all members by selecting "All" radio button.
It does not allow selecting multiple members from the selection criteria.

2) Single Value Drop Down List:
 This option also offers select only 1 member at a time or select all members by selecting "All" radio button.
It does not allow selecting multiple members from the selection criteria.

3) Single Value Slide Bar:
This option also offers select only 1 member at a time or select all members by selecting "All" radio button.
It does not allow selecting multiple members from the selection criteria.

4) Drop Down Multiple Values:
This option also offers select either at 1 or multiple members a time or select all members by selecting "All" check box.

5) Drop Down Multiple Values:
This option also offers select either at 1 or multiple members a time or select all members by selecting "All" check box.
Here List of the values shown in the drop down list.


6) Drop Down Multiple Values:
This option also offers select either at 1 or multiple members a time or select all members by selecting "All" check box.
Here List of the values shown in the drop down list.

7) Custom Value List:
This option also offers select either at 1 or multiple members a time or select all members by typing the characters.

It will search the members which are related to your typed word.
If type ST, it will show the data EAST, WEST then select which ever members want to show on the report.
It is quite similar to Contains filter.
====================================================

Similarly we can apply the Quick filters for Measures.

Quick Filters are Prompts, which allows end user to select the required data, it enhance the user interactivity with reports.

Example:
1. Right click on Date field on data window, click on “Show Quick Filter”.


2. Now we get the Prompt, and we can select whichever we want to see on the report.


3. For an Example, Select 2011, 2014. Rest of the years will be filtered.

Filters

Generally we use the filters to reduce the number of records present on the report or to show only required data on the report & to improve the performance.

Tableau have the following different kind of filters
Regular Filters
Regular Filters – Dimensions
Regular Filters – Measures
        Regular Filters – Date
Quick Filters
Context Filters


=====Regular Filters - Dimensions:
All fields that are filtered show on the Filters shelf.
We can apply the Regular filters either by dragging fields onto Filers shelf or in the view right click then select either hide or exclude.
Right click on Field from the row shelf.


=====Here we can filter the data in 4 different ways

General
Wildcard
Condition
Top

The below picture is having the data without applying any filters.
a. General: select the required data which should only be showed on the report.( Ex: California, Florida, Texas, which is showed in the below picture)
b. Wildcard: We can filter the data by applying Wildcard. ( Ex: Sates names starts with “N”, which is showed in the below picture)
c. Condition: We can filter the data by applying condition.  ( Ex: States which sales more than 25000, which is showed in the below picture)
d. Top: We can filter the data by define top n records. ( EX: Top 6 Cities sales wise, which is showed in the below picture)

Regular Filters - Measures: (Quantitative Filters)
We can apply filter on measure fields by applying aggregation filters.

In the following example, we are applying filter on Sales which should more than or equal to 5000.

Before apply the Filter, Tableau Engine automatically defines Min & Max values

Date Filters:

We use this kind of filters to filter the Date Data type kind of Data. By using this kind of filters we can show Required Years, or Months or Quarters Data, ( Jan-2015 or Yr-2015, Q1-2013.......)
Or We can show data for Specific range. (EX:  From 1-Jan-2011 to 12-Sep-2013,.........)

EX 1: List the customers who made Transactions in Year - 2011

1) Drag [Region], [Order Date], [Customer Name] fields into Rows shelf.
2) Drag the one of Measure fields from Measures window into Column Shelf.
3) Drag the [Order Date] into Filters shelf, then it will the list , here select Years , then check the box for Year -2011.


Tableau let's filter the Date Data in 2 Different ways.
1) Relative Date Filters.
2) Range Date Filters.

*********************
Relative Date Filters.
Relative date filters are dynamic, here values are changed as system date get changes.(Operating System)

EX: Relative - Current Year
Today Date #09-Jul-2015#
Description:
If you ask this Month Sales Data, It will show you Jul-2015 Data.
If you run the same report in Next month, it will show you Aug-2015 Data.
Means here we are filtering the  Data like Current month, it will change as per the Day you run the Report.

Tableau is offering the following different kind of Relative Date Filters.

Years, Quarter, Months,........


EX: Today Date #09-Jul-2015#

Show me the Current Year Sales.
Today is #09-Jul-2015#, so it will show 2015 Data (including Future data also if database contains)

1) Drag [Region], [Order Date], [Customer Name] fields into Rows shelf.

2) Drag the one of Measure fields from Measures window into Column Shelf.

3) Drag the [Order Date] into Filters shelf, then it will the list that contains Relative & Range Filters, here select Relative then click on Years, Then Click on "This Year" radio button.

4) As of now this report shows 2015 Data.

5) If you run the same report after 1 year, it will show 2016 Data. ( DB should have 2016 data rather than it will show empty report).

EX: I want to show current Month, Quarter, Last Quarter this Year, Last month this Year, .........

I want to see last 3 Years of data on the Report.

*********************
Range Date Filters.

This kind of filters allow us to define the Static range dates.
And here we can't change date data, it means it is fixed Date filters.
EX: Today we have created a report for year - 2012, if you run the same report in net year, it will show YR-2011 data only, now we can say these filter values are fixed. ( Dont consider Parameter, Quick Filters in this scenario.)
EX:
1) Drag [Region], [Order Date], [Customer Name] fields into Rows shelf.

2) Drag the one of Measure fields from Measures window into Column Shelf.

3) Drag the [Order Date] into Filters shelf, then it will the list that contains Range Filters, here select Range then Define Starting & Ending Dates.

4) As of now this report shows 2015 Data.

5) If you run the same report after 1 year, it will show 2016 Data. ( DB should have 2016 data rather than it will show empty report).

*********************
Tableau offers filtering the data in different ways also, we can call these are static filters.

1) Year wise, Month wise, Quarter wise, Week wise,............
2) Starting Date to Till end of the Date as per data in the DB.
3) Up to certain Ending Date  from starting Date.

*********************
Removing Nulls Data from the Report.
My data have nulls in Date Columns for Some Dates, i want to remove from the Report.

EX:
1) Drag [Region], [Order Date], [Customer Name] fields into Rows shelf.

2) Drag the one of Measure fields from Measures window into Column Shelf.

3) Drag the [Order Date] into Filters shelf, then it will show the list that contains Range Filters, here select Relative then click on "Special", then click on "Non-null dates" option.

4) Now Report don't have the null Dates.