Monday, July 22, 2019

Improve Tableau dashboard/reports performance

Improve Tableau dashboard/reports performance.


Just Imagine of a day when you want to quickly pull out some insights from your data to publish numbers to your business stakeholder but your dashboard just keeps loading!!……Loading…!!..Loading!!!  Isn’t it a painful experience when you have to wait for a while to see the numbers on the dashboard? I believe, most of the business users have had experienced it. Seriously there is no use of having a tool which doesn’t show up the numbers quickly but honestly speaking the problem is not always with the tool instead it is with the way we configured the tool.
Tableau is undoubtedly one of best business reporting tools available in the market. The power of tableau can be experienced only when it is used in the proper way, what I mean here is one should know the tableau best practice and optimization methods to leverage its full potential.
Tableau helps non-technical persons to plug and play with data and draw some cool insights, here the users doesn’t need to have technical knowledge of data models, data structures, SQL and data types. Unlike Data guys business users and stakeholders usually don’t possess this skill set  all they know is business process and tableau helps them to generate Ad-hoc reports instantly giving them the freedom to self-service. These ad-hoc reports doesn’t serve over long run in the business and in turn becomes a burden when published on Tableau server.
Let’s through shed some light over Tableau’s best practices, I’m confident that by implementing the below recommendations one can definitely minimize the tableau report loading/refresh time.
Well there are some areas which are not in control of a report developer but has a significant impact on the performance like network speed, number of concurrent users accessing the tableau server OR database server, having a live connection to data source etc., these are subjective so we aren’t going to focus on these things for now,
We focus on the topics where we have full control, please be mindful of the below topics before you actually begin the report building.
·        Custom SQL
·        Live/Extract
·        Adding Data source filters
·        Sorting
·        Avoid Table views
·        Filter exclude/include options
·        Count Distinct
·        Quick Filters
·        Dashboard layout(resolution)
Custom SQL:
Custom SQL is a great feature of tableau but keep in mind that it will consume a lot of memory, custom SQL actually runs in tableau memory this means every time you interact with your report/dashboard tableau has to run the query over the network and get the results from database this is load on server. I don’t recommend custom filters on a live connection instead create a materialised view of and access it through tableau.
Live/Extract connection: Every tableau users would be aware that extract connections perform better than live connection but again this is very subjective and depends on individual business requirements. I recommend to prefer extract connections where ever possible.
Data source filters: adding data source filters will cut down the volume of data that is being loaded into tableau memory. Example if we are building a monthly report then we don’t need daily transactions in our data set, here rolling up the data to month by applying aggregation option will help to minimize the records and improves the performance. In some cases we would have a data set having data from all regions over a vast time period but the report is intended to be used by just one region/data for a just certain time period in this case applying a filter in the report will fulfill the purpose but it doesn’t add any value to have the data in tableau, instead of this we should use data source filters. The point to focus here is to analysis the business requirements before you actually start building your report, I recommend to catch-up with the business stakeholder or end users to understand what exactly they want to see in the report and work on to model your data.
Table views: One picture speaks 100 words. Tableau is a visualisation tool and should be used to aggregate data values and report through visuals.  Most of the business users, particularly finance teams loves to see row level data just like in an excel sheet, but be mindful that this is not what tableau supposed to do. Reporting row level data in using tableau table view is not at all recommended (simple and small table views to show the details is always welcome) but avoid recommending Table views to your report users. I don’t mean one shouldn’t use table views but keep in mind that tableau is a visualisation tool.
Secondary Data source:
Data blending is a powerful feature of tableau helping users to build reports that are not possible to join but try to avoid creating calculated fields which refers data from secondary sources this is again a memory killer.
Sorting: This is a quite used feature of tableau and doesn’t make any sense if I ask anyone to avoid using it but the fact is sorting is a memory consuming function. I would recommend to avoid sort on dimensions which has a long text in it I know it is not easy to avoid sort function but please put your best efforts to avoid where ever possible. Clear sorting option where it is really not required.
Quick filter: Quick filters are very handy for every report and users love to have filters all over the report but be mindful that this is a memory and performance killer. Tableau offers two ways of applying filters include values/Exclude values I recommend to make the best use of these options. If you need to show just 2 values out of 25 then don’t deselect 23 values instead use exclude option and select deselect 2 values, this has a significant effect on tableau’s behavior. This approach is usually come handy while avoiding null values in the report.
Count Distinct function:
Count Distinct is a memory killer. I know it’s not possible to avoid the CountD function but please try to avoid where ever possible.
Dashboard design and use of Action filters
·        Use “Show relevant values” option to one of two filters only, applying this on all quick filters will put a very big load on tableau server.
·        Use dashboard action filters and engage users to click and drill down the reports instead of showing all quick filters on dashboard.
·        Give a type in feature for given quick filter instead of multiple select values.
·        Prefer Range over automatic size option in dashboard. Automatic is a very good option when your report is viewed across various screen sizes but keep in mind that tableau need to serve every screen size when a request is received this means extra load on tableau server. Always create respective layouts like desktop, tablet and mobile instead of automatic(Exception is when you are have less number of users hitting the tableau server then automatic size is not a big load).
There are few more topics which have moderate impact of performance and would discuss over those in some other article. To sum up the above discussed concepts
Avoid in the first place Data volume, Sorting, filter conditions, Tabular data, custom SQL and showing up quick filters.
Significant impact but out of control: Data types, Hardware, Load on server, concurrent users and Extract/Live connections.










Dynamically change the Tableau data formats like % , $ and number using parameters


Dynamically format the number with %, $ or any other style based on selected Parameter value

The requirement is to dynamically change the number format based on parameter value.
For instance, Parameter has got two values Revenue and Quantity.
When Revenue is selected report must show % symbol and on selecting parameter value to Quantity the same report should show Number

To achieve this, we need to create a parameter




Create a calculated field to drive the parameter selection
Another calculation for quantity

Drop these two calculated fields on Text marks

Essentially, what we did here is setting Null for quantity when Revenue is selected through parameter and the other way for Quantity. We can add as many number formats as we wish to this just by making other values null.

Tuesday, November 20, 2018

Show all dates in a selected financial year


Show all dates in a selected financial year

Using a parameter, if we choose Aug-2016 then we need to see all dates from April-2016 to March-2017 and if we choose Nov-2017 then we must see all dates from April-2017 to March-2018.
Solution: Create a parameter of type date which lists all months and years (use add from field option and select the date field) this parameter can be further customized to show only months-year and in ascending/descending orders making it more user friendly.
The parameter should looks like the below image.


Create a calculated field as shown below
This calculation is set to show all dates from April to March using a value of -3. But, you are free to change the number as according to your Financial calendar. Add this calculation to filter shelf and set it to True.
The final result would look something like this.

Sunday, October 28, 2018

MTD LTD calculation in Tableau


Calculations for MTD, LMTD, YTD and LYTD


Creation of MTD, LTD, LMTD, LYTD calculations involves two steps
Firstly,
Setting the starting month of the financial year, the below calculation helps the tableau to force the calendar year to consider from the offset month mentioned in the calculation. The same thing can be achieved using date option set to the FY start month in tableau and skip the setting FY process.

Setting FY to start from April

Create a parameter choose date
Create a calculated field to offset the date to April. Date of accounting is the available date in DB. And
Choose a date is a date filed created using parameter
Calculated field name = FY-Date of Accounting
//This will move the date to 3 months ahead to 3months from Jan to (Jan to April)
DATEADD ('month', 3, [Date Accounting])
Create a parameter Choose Date with date type and Create a calculated field name= FY Choose Date
//This will set the parameter to sync with the FY calculation
DATEADD ('month', 3, [Choose Date])

Create MTD calculation field

Month to date (MTD)
IF DATEDIFF ('year', [FY-Date of Accounting], [FY Choose Date]) =0
AND
MONTH ([FY-Date of Accounting]) =MONTH ([FY Choose Date])
THEN
[AMOUNTS]
END
Last month to date MTD
IF DATEDIFF ('year', [FY-Date of Accounting], [FY Choose Date]) =1
AND
MONTH ([FY-Date of Accounting]) = (MONTH ([FY Choose Date]) -1)
THEN [AMOUNTS]
END

Last year to date LYTD
IF
DATEDIFF ('year', [FY-Date of Accounting], [FY Choose Date]) =1
AND
MONTH ([FY-Date of Accounting]) <=MONTH ([FY Choose Date])
THEN
[AMOUNTS]
END

Last year Month to date     LMTD

IF
DATEDIFF ('year’, [FY-Date of Accounting], [FY Choose Date]) =1
AND
MONTH ([FY-Date of Accounting]) <=MONTH ([FY Choose Date])
THEN
[AMOUNTS]
END