tag:blogger.com,1999:blog-87952850843344833812024-02-08T00:15:52.654-06:00See it your way...Up your viz game -Newbe+ Tableau users if you are past Getting Started and ready to use Tableau to tell stories with your viz, use advanced calculations to get deeper into the data or just want to better understand why Tableau does that – then these may help you meet that goal - Enjoywww.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.comBlogger32125tag:blogger.com,1999:blog-8795285084334483381.post-5787742560377567302022-01-23T07:02:00.003-06:002022-01-23T07:02:51.151-06:00My Blog Has Moved<p> </p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-1749891013363203272021-10-30T10:06:00.013-05:002022-01-24T07:38:40.862-06:00FAQ Series - Drilling down in Top N and Other <blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p><p><br /></p><p> <span style="font-family: arial;">Frequently we see questions on how identify the Top N and group the "Other".</span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjKmwLay8XGgyHrL1-3vzB68xtEQc3QC4HaP4DVOeUGOrlB7HKXD9db5FsGyyIIE9MH29kSzkHQDeluEJea6iS1nXo9FGyb2nwaen4wmMYH37SwBmzI6xghoHGeAk7Z2QuSiIT6IwOiJvVvJm_HEFbNxuV7dypUbVM8bdbAhlC5Nil78PeeGB_zugAZ=s1300" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="724" data-original-width="1300" height="223" src="https://blogger.googleusercontent.com/img/a/AVvXsEjKmwLay8XGgyHrL1-3vzB68xtEQc3QC4HaP4DVOeUGOrlB7HKXD9db5FsGyyIIE9MH29kSzkHQDeluEJea6iS1nXo9FGyb2nwaen4wmMYH37SwBmzI6xghoHGeAk7Z2QuSiIT6IwOiJvVvJm_HEFbNxuV7dypUbVM8bdbAhlC5Nil78PeeGB_zugAZ=w400-h223" width="400" /></a></div><br /><p><br /></p><p><span style="font-family: arial;">A common problem with many business applications - determining the Top N can be easily done in a number of ways. </span><span style="font-family: arial;"> (Presented on VizConnect - see the recording at </span><a href="https://www.youtube.com/watch?v=JF20GEFB680" style="font-family: arial;" target="_blank">Link to Recording</a><span style="font-family: arial;">)</span></p><p><span style="font-family: arial;"><b>1 The Top N filter</b></span></p><p><span style="font-family: arial;">Just apply a Top N filter to the dimension</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgp0LSh1NtRlCqT5XpEy3PFm-vlC5k8HC_yywGKaaRWSKm0mXO49GyaXS3IUkSPxJjM1K9PDmLS6dfmLNvbLt0E0_l2Bwc81mMSf-FMh--5rvZnCLWSY8KDUCiv5jsxE90PLPN1-ChebRZTwGLDjOWJnRplRiv_Vbt2_h8_af17LF7PX9UZzp31saZq=s1920" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/a/AVvXsEgp0LSh1NtRlCqT5XpEy3PFm-vlC5k8HC_yywGKaaRWSKm0mXO49GyaXS3IUkSPxJjM1K9PDmLS6dfmLNvbLt0E0_l2Bwc81mMSf-FMh--5rvZnCLWSY8KDUCiv5jsxE90PLPN1-ChebRZTwGLDjOWJnRplRiv_Vbt2_h8_af17LF7PX9UZzp31saZq=w640-h360" width="640" /></a></span></div><span style="font-family: arial;"><br />A more typical question adds some complexity where the user wants to see the Top N across multiple dimensions which can be solved using Index() or Rank() </span><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;"><b>2 The Index() solution</b></span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">Index is based on the position of the record in the data table so start by sorting the data:</span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiM1qNp6FuGk5wdBAGaxFeKaokyPbrO0iHhzMJ6Ny2zl6UzmmqhATr1SBlXgv1zvfJSVS42qK7yD79WFsEKjkYwkkXHxNUz08_3My203OsO62pP97zejF61rwYR_CSdp5rtYj21siLKMZiDSQTTodpdfc-MJcuxtX5SVU5x8r7hG8zMdu6CLUQ3QioN=s711" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="513" data-original-width="711" height="289" src="https://blogger.googleusercontent.com/img/a/AVvXsEiM1qNp6FuGk5wdBAGaxFeKaokyPbrO0iHhzMJ6Ny2zl6UzmmqhATr1SBlXgv1zvfJSVS42qK7yD79WFsEKjkYwkkXHxNUz08_3My203OsO62pP97zejF61rwYR_CSdp5rtYj21siLKMZiDSQTTodpdfc-MJcuxtX5SVU5x8r7hG8zMdu6CLUQ3QioN=w400-h289" width="400" /></a></div><br /><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">Add the Index() (note can be hidden)</span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgzDxhjB6-fv49mj683FObaPDLeUfPPJUiPy7mAmDfDNk_gJOPFuA-Hn9w8OYkZyMMOoR5E_z03qe5pt70GVxI2TY949Oh2If1NeN4axR51QO1usXiXtXwXLwmWjoUuGpJozi8kBr5P1amMli9bChIxT6bZUbMrdlwZxNxm-nYbempHrgPrn-YYp9u6=s785" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="520" data-original-width="785" height="265" src="https://blogger.googleusercontent.com/img/a/AVvXsEgzDxhjB6-fv49mj683FObaPDLeUfPPJUiPy7mAmDfDNk_gJOPFuA-Hn9w8OYkZyMMOoR5E_z03qe5pt70GVxI2TY949Oh2If1NeN4axR51QO1usXiXtXwXLwmWjoUuGpJozi8kBr5P1amMli9bChIxT6bZUbMrdlwZxNxm-nYbempHrgPrn-YYp9u6=w400-h265" width="400" /></a></div><br /><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">and finally add a filter set to N</span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEidTmje899SxpMfTvNKHS66pgnmE7QYz8TvVfmSFHaromQOgyhtQdsfptn4_L_tyNAfy9A948oLAfSUKbo9hr1JPAK7CxjHJodQqYzOI-pcxDtv1yjHrKsag-uBDB2kUclWzzXzDfnTH7ftUjlxD1p6_plNaZpnIbRU72oW_mlLi6ndkZAGukBV7UnZ=s674" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="618" data-original-width="674" height="366" src="https://blogger.googleusercontent.com/img/a/AVvXsEidTmje899SxpMfTvNKHS66pgnmE7QYz8TvVfmSFHaromQOgyhtQdsfptn4_L_tyNAfy9A948oLAfSUKbo9hr1JPAK7CxjHJodQqYzOI-pcxDtv1yjHrKsag-uBDB2kUclWzzXzDfnTH7ftUjlxD1p6_plNaZpnIbRU72oW_mlLi6ndkZAGukBV7UnZ=w400-h366" width="400" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">It works well but there is a need to pre sort the data and when there are multiple dimensions you will need to determine which column to use in the sort: </span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgrPFjZcNtlB2i49ZMn6xhQYsbjs5Jxht1ZIITJ742wc-vUram6Hh7jtvNkpaOnCR4c4l0rNdLg-HE9Sn-yCeEJH-bYtVupDb3Ko2NUJwfElpoDCjj6X6MIyX5MVNS1_S_CGdzK6BJiqhcM9wfKOmyp6TpTPb9gY7fsxL00SGdrVpiaG5WxoIpBCA8u=s1920" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/a/AVvXsEgrPFjZcNtlB2i49ZMn6xhQYsbjs5Jxht1ZIITJ742wc-vUram6Hh7jtvNkpaOnCR4c4l0rNdLg-HE9Sn-yCeEJH-bYtVupDb3Ko2NUJwfElpoDCjj6X6MIyX5MVNS1_S_CGdzK6BJiqhcM9wfKOmyp6TpTPb9gY7fsxL00SGdrVpiaG5WxoIpBCA8u=w640-h360" width="640" /></a></div><br /><span style="font-family: arial;"><b>3 The Rank solution</b></span><p></p><p><span style="font-family: arial;">An alternative is to use a ranking based on either a measure or an LOD. All forms of Rank are table calculations and look something like this:</span></p><p style="text-align: center;"><span style="font-family: arial;"><b>RANK_UNIQUE(sum([Sales]),'desc')</b></span></p><p><span style="font-family: arial;">and each segment can be treated independently without presorting the data:</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEj1aKnRAMqQFjwlCp8L53Oi9igzbzR3Ig9Z9UOmk9XmFyAj2nWVSmYT-MM87kLwdQmhrbxfW1KCIX7AGwTvZzBVtP6PEhUs-5bGyQDCdP2oOMLzL5EL5Shc8cA-a7Jytra1UDyZHFgOA_ebK6vz-kMPY_nMDbkQypKy7ZVaBrI4CV89XyTmvPQ72Kyi=s1920" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/a/AVvXsEj1aKnRAMqQFjwlCp8L53Oi9igzbzR3Ig9Z9UOmk9XmFyAj2nWVSmYT-MM87kLwdQmhrbxfW1KCIX7AGwTvZzBVtP6PEhUs-5bGyQDCdP2oOMLzL5EL5Shc8cA-a7Jytra1UDyZHFgOA_ebK6vz-kMPY_nMDbkQypKy7ZVaBrI4CV89XyTmvPQ72Kyi=w640-h360" width="640" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;"><b>4 Top N and Other</b></span></p><p><span style="font-family: arial;">Users often want to see the Top N individually and group the remaining as "Other". It requires a complex solution that combines both LOD's, Table Calculation, the use of Show/Hide filters and a hack </span></p><p><span style="font-family: arial;">Start with an LOD to find the Top N and "Other" based on subcategory and region (Note I am using Include to support drilling down into the Region Hierarchy) :</span></p><p style="text-align: center;"><span style="font-family: arial;"><b>{ INCLUDE [Region],[Category]:sum([Sales])}</b></span></p><p><span style="font-family: arial;">and then Rank the LOD </span></p><p style="text-align: center;"><span style="font-family: arial;"><b>rank(sum([6 lod sales region subcat]),'desc')</b></span></p><p><span style="font-family: arial;">to start building a data table for the viz like this </span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiDKxEZVTl2306WbqYbZirpN4QpHHESlrd2A_GcJ_C_BjtaTg9BkNiOq5O5dv9iNwV_lzg-QI54DvWpdgyw5mq4Es6ZLnNwx3J4t_suyPHxycuh-VY1VOK3cDz-86C2L--EcBwafWaTZzehQg3N1HdFx6USCQS0j35LJPlc3xoxX_LV2sT47BSlS1tR=s910" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="590" data-original-width="910" height="414" src="https://blogger.googleusercontent.com/img/a/AVvXsEiDKxEZVTl2306WbqYbZirpN4QpHHESlrd2A_GcJ_C_BjtaTg9BkNiOq5O5dv9iNwV_lzg-QI54DvWpdgyw5mq4Es6ZLnNwx3J4t_suyPHxycuh-VY1VOK3cDz-86C2L--EcBwafWaTZzehQg3N1HdFx6USCQS0j35LJPlc3xoxX_LV2sT47BSlS1tR=w640-h414" width="640" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">for flexibility I added a parameter to set the N level for the Top N and created this T/F calculation</span></p><p style="text-align: center;"><span style="font-family: arial;"><b>[6 rank for lod sub reg]<=[N to top N]</b></span></p><p><span style="font-family: arial;">and used this to add a Label to the "Other" group</span></p><p style="text-align: center;"><span style="font-family: arial;"><b>if [6 rank tf ] then attr([Sub-Category]) else "Other" end</b></span></p><p><span style="font-family: arial;"> the data table now look like this:</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiFSXDfBMOmhAPfGGcwwchtqkl5IWk7ldeZzEcNE-vJ_qkWMl4yImJ1qzi7iBIaHhRYn8v3rcQ3dL7LzjzEsxN5zSUCnfAKIw8PI19nk3geRZNL934m5vtYFQgZ44BK9B8mTtnbBLK4rA8WiWKciFXSQUoMzPsoGzaldsdPkZZlV26nCie3fs_GR0Im=s1142" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="636" data-original-width="1142" height="356" src="https://blogger.googleusercontent.com/img/a/AVvXsEiFSXDfBMOmhAPfGGcwwchtqkl5IWk7ldeZzEcNE-vJ_qkWMl4yImJ1qzi7iBIaHhRYn8v3rcQ3dL7LzjzEsxN5zSUCnfAKIw8PI19nk3geRZNL934m5vtYFQgZ44BK9B8mTtnbBLK4rA8WiWKciFXSQUoMzPsoGzaldsdPkZZlV26nCie3fs_GR0Im=w640-h356" width="640" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">use a table calculation to total the "Other" </span></p><p style="text-align: center;"><span style="font-family: arial;"><b>window_sum(if [6 subcat and other label]="Other" then sum([6 lod sales region subcat]) end)</b></span></p><p><span style="font-family: arial;">and restart every Region places the Other Total on all subcategories not in the Top N - after sorting the table now looks like this</span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjebXhE8uM2RLLNTAfux7eX9G6dXEHPYH64fyiAzLtdnu9R_HKuOKLucjVcjNhTv5nNfnwwXYuN9L3pxcI3-3vKf7zDUR8nDux0FnHMnhQZGd_X3ktcAFAiuZ6hpek8mlLd4sx0V6ZxVDk9KVDE2nsNqXBHzhCxMjFwosnjZsCFcnXFtVWOTzyWHw0S=s1920" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/a/AVvXsEjebXhE8uM2RLLNTAfux7eX9G6dXEHPYH64fyiAzLtdnu9R_HKuOKLucjVcjNhTv5nNfnwwXYuN9L3pxcI3-3vKf7zDUR8nDux0FnHMnhQZGd_X3ktcAFAiuZ6hpek8mlLd4sx0V6ZxVDk9KVDE2nsNqXBHzhCxMjFwosnjZsCFcnXFtVWOTzyWHw0S=w640-h360" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><p><br /></p><p><span style="font-family: arial;">Now the hack, we only want to see each of the Top N subcategories and 1 of the subcategories labeled "Other" in each region - That is done with a show hide filter:</span></p><p style="text-align: center;"><span style="font-family: arial;"><b>if [6 rank for lod sub reg]<=[N to top N]+1 then "show" else "hide" end</b></span></p><p><br /></p><p><span style="font-family: arial;">After applying the filter and hiding the real subcategory labels the data table is complete</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEg_TIYXiEQroszS8OtcBO_3Pby0Eamo6ZTV3snS1ckXn-w2QHkg3y6-auXv8AydVBarDOeFvctPGsbj_baDrLDgzS4AeHkKzzEj40u6FYy3bxq7qRsZAYDUIsCSJM68t5N7BAIPImP_ufeUNj93_DdBNlvemLl0WUHPjrLDAIZNAQOVrC2ESIswmyNo=s1920" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/a/AVvXsEg_TIYXiEQroszS8OtcBO_3Pby0Eamo6ZTV3snS1ckXn-w2QHkg3y6-auXv8AydVBarDOeFvctPGsbj_baDrLDgzS4AeHkKzzEj40u6FYy3bxq7qRsZAYDUIsCSJM68t5N7BAIPImP_ufeUNj93_DdBNlvemLl0WUHPjrLDAIZNAQOVrC2ESIswmyNo=w640-h360" width="640" /></a></div><br /><span style="font-family: arial;"> as a bar chart the results look like this</span></div><div><span style="font-family: arial;"><br /></span><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgpWx__t2Br02TRjZ2ViZy54NlZYQm1q36K1e50xbCCI_HfmyJRAGaT8r4rcYXAUi5h93JT11cTAFF5W2JV8os0cjkpFJdlsiQsjn78xSp6E2Nk217qnFHDWQSmuYbNSmxwfeuQtPfYc8MMhBEBzHH6PND_0-bJy9jbHBjHfD2BCTXFg5qyE1ZWCguE=s1920" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/a/AVvXsEgpWx__t2Br02TRjZ2ViZy54NlZYQm1q36K1e50xbCCI_HfmyJRAGaT8r4rcYXAUi5h93JT11cTAFF5W2JV8os0cjkpFJdlsiQsjn78xSp6E2Nk217qnFHDWQSmuYbNSmxwfeuQtPfYc8MMhBEBzHH6PND_0-bJy9jbHBjHfD2BCTXFg5qyE1ZWCguE=w640-h360" width="640" /></a></div><br /><span style="font-family: arial;"><b>5 Drill down in Hierarchy</b><br /><br />One advantage of using the <b>Include</b> LOD is that it supports drill into the hierarchy finding the Top N at subsequently lower levels</span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">the LOD expression used here was </span></div><div><span style="font-family: arial;"> </span></div><div><div style="text-align: center;"><span style="font-family: arial;"><b>{ INCLUDE [Region],[Category]:sum([Sales])}</b></span></div><div style="text-align: center;"><span style="font-family: arial;"><b><br /></b></span></div><div><span style="font-family: arial;">which will support drilling down from Region to the State level - at the Region level and filtered for Central the bar chart looks like this </span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEih-36mxvxeez9hgEHGbEFj30wNwjYc4h7Ch-Xxw-N5DcHyiR6fT9_l1C3HiNGWqUGK8a_HIa_tbodpMwhJNe0eItfpbjzhjet2zoLjtrxWQ85eiVgQdxoSEsbicQKzSbm8McvU0-Rm_LS6SkdVf6RNUPkbvmthcVbQOrmt2KAQpMdya316NTcoRXd8=s1644" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="606" data-original-width="1644" height="236" src="https://blogger.googleusercontent.com/img/a/AVvXsEih-36mxvxeez9hgEHGbEFj30wNwjYc4h7Ch-Xxw-N5DcHyiR6fT9_l1C3HiNGWqUGK8a_HIa_tbodpMwhJNe0eItfpbjzhjet2zoLjtrxWQ85eiVgQdxoSEsbicQKzSbm8McvU0-Rm_LS6SkdVf6RNUPkbvmthcVbQOrmt2KAQpMdya316NTcoRXd8=w640-h236" width="640" /></a></div><br /><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">Drilling down in the Region hierarchy to the State level will return the Top N and Other unique to each state</span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgS9j55NE6Z57NFXM2AP_0tNsL-DdPmUd1n_wTLv8OFyAUyna44oieYELPZhsmmO9ilAoBMODDbpOMWJHfUOhWMwIyX-E9A39CGTHgPuEYMl1S-hS_-zfHAfDid9MNfTUTjsCvB48KJtsLEsETShRSvPpwPFxDOhnZUADNZGuEM8v2tycoq2LNBO7ge=s1384" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="717" data-original-width="1384" height="332" src="https://blogger.googleusercontent.com/img/a/AVvXsEgS9j55NE6Z57NFXM2AP_0tNsL-DdPmUd1n_wTLv8OFyAUyna44oieYELPZhsmmO9ilAoBMODDbpOMWJHfUOhWMwIyX-E9A39CGTHgPuEYMl1S-hS_-zfHAfDid9MNfTUTjsCvB48KJtsLEsETShRSvPpwPFxDOhnZUADNZGuEM8v2tycoq2LNBO7ge=w640-h332" width="640" /></a></div><br /><span style="font-family: arial;"><br /></span></div><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">Hope this helps the next time you need to find the Top N and group the Other</span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">The examples used here,and a few others, can be downloaded at <a href="https://public.tableau.com/app/profile/jim.dehner/viz/TopNOther/Titleslide" target="_blank">workbook here</a></span></p><p><span style="font-family: arial;">Enjoy</span></p><p><span style="font-family: arial;">Jim </span></p><p><span style="font-family: arial;"><b><br /></b></span></p></div>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-54285070801447462152021-10-04T06:51:00.007-05:002022-01-24T08:51:52.608-06:00Sets and Filters the Condition and Top N Tabs - What do they do?<blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p><p><br /></p><p><br /></p><p> <span style="font-family: arial;">Using</span> <span style="font-family: arial;"> Filters and Sets is nothing new - but how often do you use the "Condition" or "Top N" tabs - and have you ever used them together.</span></p><p><span style="font-family: arial;">Here we are going to look at how to use Conditions and Top N in combination with Sets and Filters - </span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRmK3jC4WXvTIHzfwMdnBJWouMVSAipXDB_RRd2t0wzRspKwi0EFCUnWGGMuJbO4xqU_7XUDupsUpANr3DHnEKE5_VevIMZOeykqmLer3tD9BFuIPpGo0qLaI7ve_hRq9IWwUWNWKbnao/s1306/focus+slide.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="739" data-original-width="1306" height="226" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRmK3jC4WXvTIHzfwMdnBJWouMVSAipXDB_RRd2t0wzRspKwi0EFCUnWGGMuJbO4xqU_7XUDupsUpANr3DHnEKE5_VevIMZOeykqmLer3tD9BFuIPpGo0qLaI7ve_hRq9IWwUWNWKbnao/w400-h226/focus+slide.PNG" width="400" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><p></p><p><span style="font-family: arial;">The Condition and the Top N tabs are on the setup for Sets and Filter - They look the same on each and provide the capability </span><span style="font-family: arial;">to further filter the dimension used in the set or filter. The can interact with each other - in an </span><b style="font-family: arial;">AND</b><span style="font-family: arial;"> fashion and can be used in combinations with filters on other dimensions or sets - (Presented at VizConnect <a href="https://www.youtube.com/watch?v=gVtUaqFiHio" target="_blank">Link to Recording</a>)</span></p><p><span style="font-family: arial;"><b>Example 1 - Simple Filter</b></span></p><p><span style="font-family: arial;">Using Superstore data, </span><span style="font-family: arial;">I've created a parameter on Region and a filter on State with this formula on the condition tab - </span></p><p style="text-align: center;"><b><span style="font-family: arial;">Sum([Sales])>10000 </span><span style="font-family: arial;">and Max(Region) = [Region Parameter]</span></b></p><p><span style="font-family: arial;">The Formula window works like and LOD - dimensions and measures must be aggregated and you can not use ATTR(). The condition will filter out all States with total sales less tha10000 and only states in the Region selected in the parameter will be included.</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div style="text-align: center;"><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm-b100HkZJ0afmNzxA6SzCnu-Ae_nwGWf8O4MZsIa7UBtOVrLYX_4jRURxDoIPbTpWieqZvNHEWdglK5k_Dh2lNPyh7W3AywAKYKwzK_YvmVYeiw8hl4XxVpIpoOH3kMdmDyOa0wbngw/s748/filtered+sales.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="554" data-original-width="748" height="296" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm-b100HkZJ0afmNzxA6SzCnu-Ae_nwGWf8O4MZsIa7UBtOVrLYX_4jRURxDoIPbTpWieqZvNHEWdglK5k_Dh2lNPyh7W3AywAKYKwzK_YvmVYeiw8hl4XxVpIpoOH3kMdmDyOa0wbngw/w400-h296/filtered+sales.PNG" width="400" /></a></div><br /><span style="font-family: arial;"><br /></span></div><span style="font-family: arial;">Now add in a Top N type filter ( I used the Bottom 4)</span><div><span style="font-family: arial;"><br /></span><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQHUV602popq-8-4sZQ5qzLAAossI0RNaL_EBsVXGNwl1TIQ2EO2sOgq_977Y9xto0Um6UCoN69mg7dZwna3fgIXgEboGiD6EJOgrMzUyXjYQEDFy0Y4l8for9wN6V6AkmXHtVVLzmzY0/s1119/add+in+bottom+4+filter.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="693" data-original-width="1119" height="248" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQHUV602popq-8-4sZQ5qzLAAossI0RNaL_EBsVXGNwl1TIQ2EO2sOgq_977Y9xto0Um6UCoN69mg7dZwna3fgIXgEboGiD6EJOgrMzUyXjYQEDFy0Y4l8for9wN6V6AkmXHtVVLzmzY0/w400-h248/add+in+bottom+4+filter.PNG" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><span style="font-family: arial;">And the Bottom N is applied in addition <b>( AND </b>filtering <b>)</b> to the filters applied on the condition tab.</span><p><span style="font-family: arial;">Before seeing more complex examples we need to see how the Order of Operation will affect the filtering. </span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq_2uXmnSxOevNpomSZ7iZnQF4WVZhU-Vk5cd2YO73rQwQ8pGkZnHlhyphenhyphenbTnUOtEvmiXJZJtdUKnAblB4QktSjr__8zhPQVNLdl3OjILwA7V1uguAobSn0tUAD0E-OjrMVnMNubFb4pz2A/s1321/2+the+OOO+affect.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="749" data-original-width="1321" height="362" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq_2uXmnSxOevNpomSZ7iZnQF4WVZhU-Vk5cd2YO73rQwQ8pGkZnHlhyphenhyphenbTnUOtEvmiXJZJtdUKnAblB4QktSjr__8zhPQVNLdl3OjILwA7V1uguAobSn0tUAD0E-OjrMVnMNubFb4pz2A/w640-h362/2+the+OOO+affect.PNG" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><span style="font-family: arial;">The Top N filter takes place in Step 4 in the Order of Operations along with the creation of Sets and Fixed LOD's expressions. That is after Context Filters but before Dimension filters are applied. It is also before any other type of calculations including Table Calculations are determined in steps 7 through 10 - </span><p></p><p><b><span style="font-family: arial;">Example 2 - Top N Filter with Context Filter</span></b></p><p><span style="font-family: arial;">We will start with a Superstore example to find the Top 7 States based on sales </span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJBTt18-hX4W5qjtLPnHtCQxthzBeGPUc6UtdO-AxC8UbjyWaZ1prM9R7NetPyqiZUNZdN8MgCaLC_2KE2542Ice81BAOHVsslt2zc16QgaRg5VzAIh3WHsryJCDGbbWiJjfuR5MZNJWE/s781/top+7+with+region+in+Context.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="633" data-original-width="781" height="324" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJBTt18-hX4W5qjtLPnHtCQxthzBeGPUc6UtdO-AxC8UbjyWaZ1prM9R7NetPyqiZUNZdN8MgCaLC_2KE2542Ice81BAOHVsslt2zc16QgaRg5VzAIh3WHsryJCDGbbWiJjfuR5MZNJWE/w400-h324/top+7+with+region+in+Context.PNG" width="400" /></a></span></div><span style="font-family: arial;"><br /> </span><p></p><p><span style="font-family: arial;">With Region in Context the filter will return in 7 state with the greatest sales from the regions in the view</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNUHiqFomLtp8Je_juFqAlUMiavqgcwf56CrwDrxuwzxLPqNzoFGrFupbSUqqkJPM26UdF2XiKHbjnvTCMXqsv_vNmDnpn1NSiHYZ0sJsgNE_O5sMyXpgxp0-BwyJsGn9kVptyT-Fa9tc/s1712/top+7+fro+the+sount+and+west.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="780" data-original-width="1712" height="183" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNUHiqFomLtp8Je_juFqAlUMiavqgcwf56CrwDrxuwzxLPqNzoFGrFupbSUqqkJPM26UdF2XiKHbjnvTCMXqsv_vNmDnpn1NSiHYZ0sJsgNE_O5sMyXpgxp0-BwyJsGn9kVptyT-Fa9tc/w400-h183/top+7+fro+the+sount+and+west.PNG" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><span style="font-family: arial;">if Region is removed from Context the top 7 are determined before the Region filter is applied and </span><p></p><p style="text-align: center;"></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi27scQ0pZUltHicVnXm3uWCkK0q12xnUkVJGAY8deohnPkxVvfxdfB8RVJ4UFOnZgEu7cdWS3J85gNwu7yPWRHnkp2SZW65bRRLTWZDgQAaSZl7ofd-Oyt81pzHsjwGIjzkTFz4FbigkY/s1920/top+7++region+Not+in+context.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi27scQ0pZUltHicVnXm3uWCkK0q12xnUkVJGAY8deohnPkxVvfxdfB8RVJ4UFOnZgEu7cdWS3J85gNwu7yPWRHnkp2SZW65bRRLTWZDgQAaSZl7ofd-Oyt81pzHsjwGIjzkTFz4FbigkY/w400-h225/top+7++region+Not+in+context.png" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><p><span style="font-family: arial;"><b>Example 3 - Multi Dimension Top N Sets </b></span></p><p><span style="font-family: arial;">Now let's look at combining additional dimensions in the Top N. We still want the top 7 States but the users also wants the top 7 based on the total sales of selected subcategories - </span></p><p><span style="font-family: arial;">First we need an LOD to determine the sales at the combination of State and Subcategory</span></p><p style="text-align: center;"><span style="font-family: arial;"><b>{ FIXED [Sub-Category],[State]:sum([Sales])}</b></span></p><p><span style="font-family: arial;">Next create a set with this condition </span></p><p style="text-align: center;"><span style="font-family: arial;"><b>sum({ FIXED [State],[Sub-Category]: sum([Sales])} )= </b></span></p><p style="text-align: center;"><b style="font-family: arial;">sum([3 LOD sales by subcat and state]) </b></p><p style="text-align: center;"><b style="font-family: arial;"><br /></b></p><p><span style="font-family: arial;">and add in the Category and subcategory Filter to Context - and the set will include the 7 states that have the max total sales based on the filter subcategories </span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7RYPw7mgkQoak845hDzAxkV-JhnxRHdNHHKzgWKLbj2YdK7HBagw7tXnkmCsonL_sowFOY-wdbVmHRyVIXYaUrKBSbcwHp6ICm1mTiohznoDHIB_XRCjH_lpWE0VIoabR3dm__jAeA1w/s1624/7+states+based+on+filter+subcats.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="791" data-original-width="1624" height="195" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7RYPw7mgkQoak845hDzAxkV-JhnxRHdNHHKzgWKLbj2YdK7HBagw7tXnkmCsonL_sowFOY-wdbVmHRyVIXYaUrKBSbcwHp6ICm1mTiohznoDHIB_XRCjH_lpWE0VIoabR3dm__jAeA1w/w400-h195/7+states+based+on+filter+subcats.PNG" width="400" /></a></span></div><span style="font-family: arial;"><br /> </span><p></p><p><span style="font-family: arial;">when the subcategories are changed the Top 7 adjust :</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYrL4L8ZI41QBustgnzVKwuMdmrGVHOja0oKT_PHhY2vcTw3bRAizZUZyvWSrfuUbqdIvmGwu1piwE-M7ajObswsnyyEwtZ29B6gUQexzywf1E40XjU4CVI-O7qSKvWcNnuhaMUHnNq44/s1353/mich+out+fla+in.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="756" data-original-width="1353" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYrL4L8ZI41QBustgnzVKwuMdmrGVHOja0oKT_PHhY2vcTw3bRAizZUZyvWSrfuUbqdIvmGwu1piwE-M7ajObswsnyyEwtZ29B6gUQexzywf1E40XjU4CVI-O7qSKvWcNnuhaMUHnNq44/w400-h224/mich+out+fla+in.PNG" width="400" /></a></div><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;"><b>Example 4 - Fixed 7 States find the Top N subcategories</b></span></p><p><span style="font-family: arial;">Users want to find the top categories within the 7 overall best States. </span></p><p><span style="font-family: arial;">Now the Order of Operation and the use of Table Calculations come into play. First, we need to first determine the top 7 states and then within each state find use Rank to order the subcategories -</span></p><p><span style="font-family: arial;">Ranking functions are table calculations that are determined in Step 10 of the OOO after the sets and lods are determined in Step 4. Using the LOD we calculated in the previous example </span></p><p style="text-align: center;"><span style="font-family: arial;"><b>{ FIXED [Sub-Category],[State]:sum([Sales])}</b></span></p><p><span style="font-family: arial;">add that to a Ranking function</span></p><p style="text-align: center;"><span style="font-family: arial;"><b>RANK_UNIQUE(sum([3 LOD sales by subcat and state]),'desc')</b></span></p><p><span style="font-family: arial;">and replace the set with the ranking function the number of categories to show</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2ovqSK5gqD8fUr-Kxsf0ym6BcE2nRchiB1nMck6p0GN6dXGK0QxRGFPfbD7fSuzO39e6_lXzuRYv600I3-fuDYtlV5leI09rbFlFsyowF-7FHzUAbf-rj5XefIW2pf0txRQkRuqIbxw4/s1920/ranking+on+map.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2ovqSK5gqD8fUr-Kxsf0ym6BcE2nRchiB1nMck6p0GN6dXGK0QxRGFPfbD7fSuzO39e6_lXzuRYv600I3-fuDYtlV5leI09rbFlFsyowF-7FHzUAbf-rj5XefIW2pf0txRQkRuqIbxw4/w400-h225/ranking+on+map.png" width="400" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><span style="font-family: arial;">It is easier to see the result in a text table format </span><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibejk7bM_2Jf9ogcbpx6MStUFpZImz4XL8oJgRKARIS75zXJrhZvBqwuW_Fna_eV89hLB4zeYQYOA-nIyPekqLraGC6mqBO9-M-WHXPIB12tZUnHuIv8vJ__KWP1mnHXx5PoK-8og52hc/s1920/top+subcat+text+table.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibejk7bM_2Jf9ogcbpx6MStUFpZImz4XL8oJgRKARIS75zXJrhZvBqwuW_Fna_eV89hLB4zeYQYOA-nIyPekqLraGC6mqBO9-M-WHXPIB12tZUnHuIv8vJ__KWP1mnHXx5PoK-8og52hc/w640-h360/top+subcat+text+table.png" width="640" /></a></div><br /><span style="font-family: arial;">The top 7 States overall are first determined then the top 3 subcategories are identified in each state</span><p><span style="font-family: arial;"><b>Example 5 - the Reset Button </b></span></p><p><span style="font-family: arial;">Ever have a dashboard where you've applied a several filters and you would like to "Reset them" with a single click - It can be done with a "Reset Button" - No magic here just the creative use of an action filter </span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrkLO3eGla7li6cw6nU7X1FJFLTT9JEc9RmObnE5zvIZ6HrPeudALjiOj3jZL28muGnN3BXj41NOrxfvUFQUD7THfkM-acur983PyrfiKfwLEaM5J-7TvUp9sxYiWL7br5tmVtK85Hllw/s1920/Reset+Button+and+map.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrkLO3eGla7li6cw6nU7X1FJFLTT9JEc9RmObnE5zvIZ6HrPeudALjiOj3jZL28muGnN3BXj41NOrxfvUFQUD7THfkM-acur983PyrfiKfwLEaM5J-7TvUp9sxYiWL7br5tmVtK85Hllw/w400-h225/Reset+Button+and+map.png" width="400" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">Create a worksheet with a shape and a label - </span></p><p><span style="font-family: arial;">then on a dashboard </span><span style="font-family: arial;">add an Action Filter - from the Rest button to sheet where the filters are applied - the select each filter you want to reset - you will get a Warning Message but that is not a problem</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXYq3P6Eu-Ok8apX9dwOpO4jDIolqcA4ecRqAQXK2MERddeLoGtNICkKsfTh0dgAj7ux2FYZTP9rkvAxMXxx6kQdw-o4xcfRF8IGdQEeoS3xuuMFPLJpHReYLCnFIQ7TJTwb6P8l4f_dw/s1920/Action+restet.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXYq3P6Eu-Ok8apX9dwOpO4jDIolqcA4ecRqAQXK2MERddeLoGtNICkKsfTh0dgAj7ux2FYZTP9rkvAxMXxx6kQdw-o4xcfRF8IGdQEeoS3xuuMFPLJpHReYLCnFIQ7TJTwb6P8l4f_dw/w640-h360/Action+restet.png" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><span style="font-family: arial;">Select the rest button will return all values to the filters</span><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiatwv9fGT9zhEJmVayGyOHK979Vj6PWEI6WUErJdiSJk6fWpx2F3lrfx332nct8N6Z833BAeJnF93Z0iLawLesG0eX7EWcNR-uXTwkwMsIRk_6N1pdJxH4gXCmf5abmInlOkUSreaIg4k/s1920/reset+complete.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiatwv9fGT9zhEJmVayGyOHK979Vj6PWEI6WUErJdiSJk6fWpx2F3lrfx332nct8N6Z833BAeJnF93Z0iLawLesG0eX7EWcNR-uXTwkwMsIRk_6N1pdJxH4gXCmf5abmInlOkUSreaIg4k/w400-h225/reset+complete.png" width="400" /></a></div><br /><span style="font-family: arial;"><b>Example 6 Default Values for filters</b></span><p></p><p><span style="font-family: arial;">Some users want set default values for filters and it can be done with some creativity using a parameter ( Credit for this goes to Joshua Milligan - Tableau Zen Master Hall of Fame - <a href="https://www.tableau.com/about/blog/2015/8/how-dynamically-set-default-values-quick-filters-43563?_ga=2.13714039.1747721645.1629108922-1933565739.1619287583" target="_blank">Link to Joshua's work</a> ) It is done by first creating a parameter on Region and adding in 2 values - All and Default</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu_ZI0j8jq0XIYVG42G8b4KKtx7XHK7mBCh60fauHNindvFaEKeQQBSq12msboXDbugfskQ803ckwf9hhioChcntVkgWcCrMR49UgCOXjlNxWrMpXJgcRgks-LtDXMTXM3Ka_JVsFHkbc/s505/region+all+default+param.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="505" data-original-width="446" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu_ZI0j8jq0XIYVG42G8b4KKtx7XHK7mBCh60fauHNindvFaEKeQQBSq12msboXDbugfskQ803ckwf9hhioChcntVkgWcCrMR49UgCOXjlNxWrMpXJgcRgks-LtDXMTXM3Ka_JVsFHkbc/w354-h400/region+all+default+param.PNG" width="354" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">Next create a case statement for Default In this example there are 4 States we want for the when the user selects Default - they are connected with <b>OR</b></span></p><p align="center" style="margin: 0in; text-align: center;"><b><span face="Arial, sans-serif" style="font-size: 13.5pt;">CASE [Region Param with all and default]</span></b><span style="font-size: 13.5pt;"><o:p></o:p></span></p><p align="center" style="margin: 0in; text-align: center;"><b><span face="Arial, sans-serif" style="font-size: 13.5pt;">When "Default" then</span></b><span style="font-size: 13.5pt;"><o:p></o:p></span></p><p align="center" style="margin: 0in; text-align: center;"><b><span face="Arial, sans-serif" style="font-size: 13.5pt;">[State] ="New York" or</span></b><span style="font-size: 13.5pt;"><o:p></o:p></span></p><p align="center" style="margin: 0in; text-align: center;"><b><span face="Arial, sans-serif" style="font-size: 13.5pt;">[State] = "Illinois" or</span></b><span style="font-size: 13.5pt;"><o:p></o:p></span></p><p align="center" style="margin: 0in; text-align: center;"><b><span face="Arial, sans-serif" style="font-size: 13.5pt;">[State]= "Florida" or </span></b><span style="font-size: 13.5pt;"><o:p></o:p></span></p><p align="center" style="margin: 0in; text-align: center;"><b><span face="Arial, sans-serif" style="font-size: 13.5pt;">[State]= "Washington"</span></b><span style="font-size: 13.5pt;"><o:p></o:p></span></p><p style="text-align: center;"><span style="font-family: arial;"></span></p><p align="center" style="margin: 0in; text-align: center;"><b><span face="Arial, sans-serif" style="font-size: 13.5pt;">end</span></b><span style="font-size: 13.5pt;"><o:p></o:p></span></p><p><span style="font-family: arial;">then we just need a TF filter </span></p><p align="center" style="margin: 0in; text-align: center;"><b><span face="Arial, sans-serif" style="font-size: 13.5pt;">[Region Param with all and default] = "All" or </span></b><span style="font-size: 13.5pt;"><o:p></o:p></span></p><p align="center" style="margin: 0in; text-align: center;"><b><span face="Arial, sans-serif" style="font-size: 13.5pt;">[Region]=[Region Param with all and default]</span></b><span style="font-size: 13.5pt;"><o:p></o:p></span></p><p align="center" style="margin: 0in; text-align: center;"><b><span face="Arial, sans-serif" style="font-size: 13.5pt;">or CASE [Region Param with all and default]</span></b><span style="font-size: 13.5pt;"><o:p></o:p></span></p><p align="center" style="margin: 0in; text-align: center;"><b><span face="Arial, sans-serif" style="font-size: 13.5pt;">when "Default" then [8 Default state from region]</span></b><span style="font-size: 13.5pt;"><o:p></o:p></span></p><p style="text-align: center;"><span style="font-family: arial;"></span></p><p align="center" style="margin: 0in; text-align: center;"><b><span face="Arial, sans-serif" style="font-size: 13.5pt;">end</span></b><span style="font-size: 13.5pt;"><o:p></o:p></span></p><p><span style="font-family: arial;">When All is selected in the Region parameter the statement returns a True. if the user selects and single region just that region will return a True. When Default is selected the Default case statement returns a True for the 4 states and returns this </span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7rkdaE5TS4vfO4LgOe_ozzllm8TTro1z7kaOWDqUxnnc0b-aw3ojNe4H9kpRiNbsNQAHDDo7cEgkY37UphThFhi60NmtiODXyEA3V394tDKWmaLLjmyUmIWfVhjoOq51AIet8IHY3ev4/s1920/default+return.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7rkdaE5TS4vfO4LgOe_ozzllm8TTro1z7kaOWDqUxnnc0b-aw3ojNe4H9kpRiNbsNQAHDDo7cEgkY37UphThFhi60NmtiODXyEA3V394tDKWmaLLjmyUmIWfVhjoOq51AIet8IHY3ev4/w400-h225/default+return.png" width="400" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;"><b>Example 7 Cascading Parameters</b></span></p><p><span style="font-family: arial;">Frequently users want to have the drop down values in one parameters be dependent on the value of another parameter. Currently that is not capable in "out of the box Tableau" and I have responded to users to use a parameter and a "Relevant Value Filter or Set" on the Condition Tab like this:</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoyvU_EORpgY4xmrdKBX6Wm9-etwqYMx3gKelPU_773OKsACzOU9TsHhrO2U2rHqAAGrXHl_9H7hMIy5CGuWGWWmnmOaUalSZEcb_Eae7woEANSOnEqjo35A_lqF30lNf1pNjfrfj4c_o/s589/rv+set+cond.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="589" data-original-width="448" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoyvU_EORpgY4xmrdKBX6Wm9-etwqYMx3gKelPU_773OKsACzOU9TsHhrO2U2rHqAAGrXHl_9H7hMIy5CGuWGWWmnmOaUalSZEcb_Eae7woEANSOnEqjo35A_lqF30lNf1pNjfrfj4c_o/w304-h400/rv+set+cond.PNG" width="304" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">Which would create a set base on the parameter and only show the IN values in the set </span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ5E4sjUKwDF2rILIa5LUyFB_A_BsrR8uFrsVfAt7tDrMiCUibMogLhjUZx-isgO4cRRP9XKx3c3lW7II_mboNs3gSuEkMsj121BDFnLo6VuLenhEKui2vI2LWktpf_f64nEG0pnkEWRs/s1920/RV+set+output.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ5E4sjUKwDF2rILIa5LUyFB_A_BsrR8uFrsVfAt7tDrMiCUibMogLhjUZx-isgO4cRRP9XKx3c3lW7II_mboNs3gSuEkMsj121BDFnLo6VuLenhEKui2vI2LWktpf_f64nEG0pnkEWRs/w400-h225/RV+set+output.png" width="400" /></a></div><br /><span style="font-family: arial;">and from there you can use the set to drill down </span><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl2tpnxc8-OzYN4wGRhCdYfs5-4UmDA9kb4B5q-0c-9DPecWQQ0vXqCtUa3N5LiNCQaiFUEJZeBLnx_WznmQNDD-OIYqdIc-yrpAtWioH8oJKevHWws8rQFpIE9hJWkX8s4vw70MipHoA/s1920/rv+drill+in.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl2tpnxc8-OzYN4wGRhCdYfs5-4UmDA9kb4B5q-0c-9DPecWQQ0vXqCtUa3N5LiNCQaiFUEJZeBLnx_WznmQNDD-OIYqdIc-yrpAtWioH8oJKevHWws8rQFpIE9hJWkX8s4vw70MipHoA/w400-h225/rv+drill+in.png" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;"><span style="font-family: arial;">If you can use extensions there is another option</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">First you need to create 2 parameters - one to drive the extension - here on Category</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"> <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_ywI8NJ6ZpjFn_l4DNrbpODR2A_Wjrg0RzShXf70583EmF4HuTyl3u2oaPlpxHp0RjRoTJS_teSi_8N49WaOmJo7HMXWfZC3NxITXBOm2d99FVSxoWZxiGwq9xQGrXQSIrfzK-kQ-nxw/s847/cascad+first+filter.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="608" data-original-width="847" height="230" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_ywI8NJ6ZpjFn_l4DNrbpODR2A_Wjrg0RzShXf70583EmF4HuTyl3u2oaPlpxHp0RjRoTJS_teSi_8N49WaOmJo7HMXWfZC3NxITXBOm2d99FVSxoWZxiGwq9xQGrXQSIrfzK-kQ-nxw/s320/cascad+first+filter.PNG" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;">Then a second parameter that will receive the values from the cascading filter and place both on the worksheet</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgia7R90acPqFX0rFWD1xA2RvGkyK96FeHBd-MLHU1lIEWP0gJvrMmWYVoEXr_jRIBqMN5vdA2msuHquEBDBfl9_iEEpi0cfOFCinDWq_gN1qajNnBmJ9mcRUtH2wwRbnpllFBBXCZ8iY/s851/cascade+2nd+param.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="611" data-original-width="851" height="230" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgia7R90acPqFX0rFWD1xA2RvGkyK96FeHBd-MLHU1lIEWP0gJvrMmWYVoEXr_jRIBqMN5vdA2msuHquEBDBfl9_iEEpi0cfOFCinDWq_gN1qajNnBmJ9mcRUtH2wwRbnpllFBBXCZ8iY/s320/cascade+2nd+param.PNG" width="320" /></a></div><br /><div class="separator" style="clear: both;"><br /></div><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">Search Parameter and select Data Drive Parameter</span></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinkekjv1hq_3HEzs4DX76CUhYH4-JZ62cnrdYV1Q3T349vw-VJ7X8ChnkldMeEXcSuHKX7npZet5mUOmbqsCYms6sYB_kYyMlKN8dyQc1P7vqgXWdr3sZOGD2gRDBwYqapvqbSFmZTOto/s1920/data+drive+param.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinkekjv1hq_3HEzs4DX76CUhYH4-JZ62cnrdYV1Q3T349vw-VJ7X8ChnkldMeEXcSuHKX7npZet5mUOmbqsCYms6sYB_kYyMlKN8dyQc1P7vqgXWdr3sZOGD2gRDBwYqapvqbSFmZTOto/w640-h360/data+drive+param.png" width="640" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">the extension needs to be configured - on the first page Identify the parameter that will accept the values (the second above), the worksheet it is on and the dimension on that sheet that relates to the values ( here subcategory)</span></p><p><span style="font-family: arial;">on the Option Tab select 'Update List when Parameter Changes' and the parameter that will drive the list (the 1st parameter - here Category Parameter)</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirsAiECv0bhGNqqVer8MYrCC4sqRWYcP_FUZlTY5OXMSAw_sPxWcDcN9zHZYUG787G1C3faPgh07L3aqtrZXb4jRs5TVdkHlJ9wifPMwvTRci-SBehUnnsA0-pyZbE3YY4-ntGRCwTuS4/s644/cascade+option+pg.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="644" data-original-width="452" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirsAiECv0bhGNqqVer8MYrCC4sqRWYcP_FUZlTY5OXMSAw_sPxWcDcN9zHZYUG787G1C3faPgh07L3aqtrZXb4jRs5TVdkHlJ9wifPMwvTRci-SBehUnnsA0-pyZbE3YY4-ntGRCwTuS4/w450-h640/cascade+option+pg.PNG" width="450" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><span style="font-family: arial;">Then create the viz and the first parameter will drive the drop down list in the second </span><p></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdDuM54EYAutRi7k6Jc0uhqddUAFVTDS6yxqo-e_CLZiQRA5MJ8jeZ-D10_itjgIDXAQ-iLm2DxSm3jmaYbPUTYfAW4WqlSD1PogYkgrtBbRxv3AVZuXmGo-HdOh0TV84tJf9gPDyz_70/s1920/cascade+with+ext.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdDuM54EYAutRi7k6Jc0uhqddUAFVTDS6yxqo-e_CLZiQRA5MJ8jeZ-D10_itjgIDXAQ-iLm2DxSm3jmaYbPUTYfAW4WqlSD1PogYkgrtBbRxv3AVZuXmGo-HdOh0TV84tJf9gPDyz_70/w400-h225/cascade+with+ext.png" width="400" /></a></div><br /><span style="font-family: arial;">I hope this help explain the use of the Condition and the Top N tabs and has given you some ideas on how you can use them in your vizes </span><p></p><p><br /></p><p><span style="font-family: arial;">The workbook used here can be found at </span><a href="https://public.tableau.com/app/profile/jim.dehner/viz/FiltersandSets-TheConditionandTopNTabs-Whatdotheydo/Focusslide" style="font-family: arial;" target="_blank">Link to Workbook</a></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Enjoy</span></p><p><span style="font-family: arial;">Jim</span></p></div>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-31168952769330902752021-08-22T07:39:00.006-05:002022-02-02T13:07:14.288-06:005 Ways to do YoY and YTD<blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p><span style="font-family: arial;"></span></p><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/2021/08/22/5-ways-to-do-yoy-and-ytd/" target="_blank"><span style="font-size: large;">UPDATED blog post</span></a></span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">YoY and YTD calculations are fundamental business metric - afterall who doesn't want to know how they compared to last year, last month or how they are tracking on a year to date basis. It seems that users at all experience levels have questions on how to complete period over period and period to date type calculations or have different expectations for the outcome. </span><span style="font-family: arial;">(See the recording </span><a href="https://www.youtube.com/watch?v=E-NfEVHjb3I">VizConnect Tableau Community Data Doctor Session August 2021 - YouTube</a> )</p><p><span style="font-family: arial;">Here we will look at 5 different approaches starting with the most straightforward - table calculations to the advanced duplicating the dataset and joining it to itself.</span></p><p><span style="font-family: arial;">I will be using subsets of Superstore data in the calculations. <i><span style="font-size: x-small;">(Note</span>:<span style="font-size: x-small;">there is a link to downloadable workbook)</span></i></span></p><p><span style="font-family: arial;"><b>1 Table Calculations</b></span></p><p><span style="font-family: arial;">The easiest way to do a period over period calculation is with a standard table calculation Percent Difference:</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEij0c6CA4aetxNp4OLuFgppjJlnjlpXQ7-itn78pNqkwct38MzJr0dAn3AL4YX7a22PLlkA52V_JyMEHAovjdvKxqIkbUi8UDGaki9wka7McK6xkEjoSphVfhTn-AqYtp2d7a9Dt_1dbyE/s1920/Per+Diff++Table+Calc.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEij0c6CA4aetxNp4OLuFgppjJlnjlpXQ7-itn78pNqkwct38MzJr0dAn3AL4YX7a22PLlkA52V_JyMEHAovjdvKxqIkbUi8UDGaki9wka7McK6xkEjoSphVfhTn-AqYtp2d7a9Dt_1dbyE/w640-h360/Per+Diff++Table+Calc.png" width="640" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">Easy enough, but most users want to eliminate the empty column for the initial year in the series. That can not be done with a table calculation</span></p><p><span style="font-family: arial;"><b>2 LOD and a fixed starting point</b></span></p><p><span style="font-family: arial;">The second method uses 2 LODs and requires a fixed starting point. That starting point be from a parameter, the current date (Today()) or the latest date in the data set {max(date)} The example uses Today() -</span></p><p><span style="font-family: arial;">The current YTD value can be determined using the LOD:</span></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><b><span style="font-family: arial;">{ FIXED [Category]: sum( if DATETRUNC("year",[Order Date])= DATETRUNC("year",TODAY())</span><span style="font-family: arial;">and DATETRUNC("day",[Order Date])<= DATETRUNC("day",TODAY()) then [Sales] end )}</span></b></p></blockquote><p><span style="font-family: arial;">Where the year of the date dimension is checked against the year of Today() and all the days in the year prior to and including Today() and included in the total. </span></p><p><span style="font-family: arial;">Similarly the prior YTD value calculation is:</span></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><span style="font-family: arial;"><b>{ FIXED [Category]: sum( if DATETRUNC("year",[Order Date])= DATETRUNC("year",dateadd("year",-1,TODAY())) </b></span><b style="font-family: arial;">and DATETRUNC("day",[Order Date])<= DATETRUNC("day",dateadd("year",-1,TODAY())) then [Sales] end )}</b></p></blockquote><p><span style="font-family: arial;">and compares the year of the date to 1 year prior to Today() using a Dateadd function.</span></p><p><span style="font-family: arial;">Then the YoY percent difference is simply calculated using:</span></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><span style="font-family: arial;"><b>(sum([Current YTD Sales (today)])-sum([Prior YTD Sales (today) ]))/</b></span></p><p><b><span style="font-family: arial;"></span></b></p><p><span style="font-family: arial;"><b>sum([Prior YTD Sales (today) ])</b></span></p></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><br /></p></blockquote><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSawoSr9yoyUTNbw9n_hc9NoG-joceDMa1NxRYqUpviqnYmVgqRGBGUOqJ8UX3pexRyPnEVeLbo7IS5OR37tZclasGnymajrS9mvA5TQzTq9OTUtQitTGruesRKIHceICNo1a4MikNWQc/s735/LOD+perecent+diff+today.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="476" data-original-width="735" height="414" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSawoSr9yoyUTNbw9n_hc9NoG-joceDMa1NxRYqUpviqnYmVgqRGBGUOqJ8UX3pexRyPnEVeLbo7IS5OR37tZclasGnymajrS9mvA5TQzTq9OTUtQitTGruesRKIHceICNo1a4MikNWQc/w640-h414/LOD+perecent+diff+today.PNG" width="640" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">The LOD approach is the one I recommend most often - the LODs for the Current and Prior YTD are portable from sheet to sheet and can be used in any other calculation. They are also easily converted to use with a parameter for the end date or the max date in the data set by substituting [Parameter Date] or {Max(date)} for Today() in the forumlas.</span></p><p><span style="font-family: arial;"><b>3 Variable period POP</b></span></p><p><span style="font-family: arial;">Often users want to compare the YTD versus PYTD or MTD versus PMTD (or more) based on a parameter selection by the end user. First a Parameter is need to select the basis for comparison</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKrYREtXJUSPAbcACTcQJTgVjoKizFwkWj71tTXESuxJ5gVNoqA81My_i210d7sepgKEbbBs4QIkGoJ1xpNQRCeXDwDry7smlNkHzUEPwee8TyxLmZy3bGuZCmNWVlN6UjiRZGl7bw68o/s595/year+month+parameter.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="443" data-original-width="595" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKrYREtXJUSPAbcACTcQJTgVjoKizFwkWj71tTXESuxJ5gVNoqA81My_i210d7sepgKEbbBs4QIkGoJ1xpNQRCeXDwDry7smlNkHzUEPwee8TyxLmZy3bGuZCmNWVlN6UjiRZGl7bw68o/s320/year+month+parameter.PNG" width="320" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">then 2 Case statements for the Current or Prior period to date totals - the case statements use LODs similar to those used in the previous example. <span style="font-size: x-small;">(Note:The formulas can be downloaded in the workbook). </span></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiA1YCvgTwMrBOv38vpTMBpD5uoF1zJd_PtR7uoE4ZKzjS7KCjEYfVsH-ZBEPMnNeXC3yAn7eyeY4Qpunk1XymX3ndeIAnQfQPRGev1rDgnD1732p7-hySOs-KsIMl3Mpk39FBXTLurjFk/s870/POP+current.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="469" data-original-width="870" height="346" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiA1YCvgTwMrBOv38vpTMBpD5uoF1zJd_PtR7uoE4ZKzjS7KCjEYfVsH-ZBEPMnNeXC3yAn7eyeY4Qpunk1XymX3ndeIAnQfQPRGev1rDgnD1732p7-hySOs-KsIMl3Mpk39FBXTLurjFk/w640-h346/POP+current.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><span style="font-family: arial;">Selecting the Year returns the YTD (July 9, 2020) versus Prior YTD (July 9, 2019) </span><p></p><p><span style="font-family: arial;">And selecting Month will compare MTD </span><span style="font-family: arial;">(July 9, 2020) to Prior MTD (June 9, 2020)</span></p><p><span style="font-family: arial;"><br /></span></p><div class="separator" style="clear: both;"><span style="font-family: arial;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifCJVARkZ8TXRHYaXyq4IJnh96j3-of-DBcG1BPGVPZrMdyb4ZzHWCpdLcMKi3VW6T230ls4NJtItIBU6l1P4RnMx4-M5SNEft_bjw4KTe-NM2nMwPZqcUVhdvz1Z5VXvpgu9a5-qJqtI/s701/YTD+POP+results.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="628" data-original-width="701" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifCJVARkZ8TXRHYaXyq4IJnh96j3-of-DBcG1BPGVPZrMdyb4ZzHWCpdLcMKi3VW6T230ls4NJtItIBU6l1P4RnMx4-M5SNEft_bjw4KTe-NM2nMwPZqcUVhdvz1Z5VXvpgu9a5-qJqtI/w266-h258/YTD+POP+results.png" width="266" /></a> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8pPaHRfBxpv4uDugk8lYvKf6CG4N4D5Bb-Sa_zPEA2WiQHPUwPv4YBclViqip9LAL4MIIHWJWycvI5pxm5n1DsnqlN9l7ntvm54mb62B2maiqK_opu-v-IFIXHnANxFFQEr3_FiukKBM/s694/Prior+month+pop.png" style="margin-left: 1em; margin-right: 1em; text-align: right;"><img border="0" data-original-height="620" data-original-width="694" height="254" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8pPaHRfBxpv4uDugk8lYvKf6CG4N4D5Bb-Sa_zPEA2WiQHPUwPv4YBclViqip9LAL4MIIHWJWycvI5pxm5n1DsnqlN9l7ntvm54mb62B2maiqK_opu-v-IFIXHnANxFFQEr3_FiukKBM/w284-h254/Prior+month+pop.png" width="284" /></a></span></div><span style="font-family: arial;"><br /></span><p></p><br /><p><span style="font-family: arial;">More levels can be added to the parameter and the case statements to look at different data part levels.</span></p><p><span style="font-family: arial;"><b>4 Dynamic YoY comparison</b></span></p><p><span style="font-family: arial;">Less frequently, a user will want to compare make a YoY comparison over a range of dates and that presents a problem with the first 3 approaches. Table calculations do a comparison by position in a data table, not by the actual date and the LOD solutions depend on fixing an end date.</span></p><p><span style="font-family: arial;">A dynamic or running YoY comparison can be done but it will take duplicating the data set and joining it to itself offsetting the date by a year. But it can only be done at levels where the data set is solid - i.e. no voids in the data set</span></p><p><span style="font-family: arial;">The first example uses a very simple data subset of the Superstore data that only includes the order date, the category, subcategory and the sales value. Step 1 is to join a copy of the data with itself at the subcategory, month and year level but offsetting the year - <span style="font-size: x-small;">(Note I have used the physical layer to explicitly join the files together )</span></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEislGPg3H8_vgd9EipK1aM1mPrYKEUtdEA5cQ93JG4xqLXje8o7zwpVk1vUEXmyCZR0l8NFYMmhB1cMjn3GrviezPuSj7aP7pDzwMbofzfBHFqVRhQMc_-Wud3PS7zOSfYrNv8z3VQG_jE/s1920/YOY+dyn+join+clause.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEislGPg3H8_vgd9EipK1aM1mPrYKEUtdEA5cQ93JG4xqLXje8o7zwpVk1vUEXmyCZR0l8NFYMmhB1cMjn3GrviezPuSj7aP7pDzwMbofzfBHFqVRhQMc_-Wud3PS7zOSfYrNv8z3VQG_jE/w640-h360/YOY+dyn+join+clause.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><span style="font-family: arial;">When you open any worksheet there will be 2 data sets in the data frame - one is the original data set</span><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWTnZpohzO98qMAtfCbIV9eseBl-9fucQXzuUTdHNSPpYI4-rGX1b9j0mTquHPkJ2WDni9k5h9n86U1zlH1eoEnN0-eGKQ3jLmMTB4dlcUtqVfIQnwufZDLWbE16GK2AH55Dy3foXSMl8/s1920/current+year+data+seet.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWTnZpohzO98qMAtfCbIV9eseBl-9fucQXzuUTdHNSPpYI4-rGX1b9j0mTquHPkJ2WDni9k5h9n86U1zlH1eoEnN0-eGKQ3jLmMTB4dlcUtqVfIQnwufZDLWbE16GK2AH55Dy3foXSMl8/w640-h360/current+year+data+seet.png" width="640" /></a></div><div><br /></div><br /><span style="font-family: arial;">and the other is the copy that was joined to create a Prior year data set</span><div><span style="font-family: arial;"><br /></span><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIFg5PSC_2iOUGiWWU7HMJhT58neSI9xLho8HbzvEpyyKOtmvz7IfJLNl47t0CTE4Bl7auvpyQrcZysunOywt9N2b8V5HgrwpUmaMMyo1MGyOdGtiwYAU1vjE3py34WOk4OIHiN2SqagA/s1920/Prior+year+data+set.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIFg5PSC_2iOUGiWWU7HMJhT58neSI9xLho8HbzvEpyyKOtmvz7IfJLNl47t0CTE4Bl7auvpyQrcZysunOywt9N2b8V5HgrwpUmaMMyo1MGyOdGtiwYAU1vjE3py34WOk4OIHiN2SqagA/w640-h360/Prior+year+data+set.png" width="640" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">The comparison can be made directly by placing the current and prior year sales on in viz and the current years on columns </span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigOs8zycPRaEVZZ96atJPqQV5WkuFZOCKHZiKaXLorx0N-lNg-pNh8nOihDnibTJo42Tnx7D0FTnShB1wfVUZ9XmU5kikye8iCRccl5GbIk3MX2uQJAWCdx8g02jmq7-e6dNDJYPDW5-Q/s1138/Dynamic+YoY.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="458" data-original-width="1138" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigOs8zycPRaEVZZ96atJPqQV5WkuFZOCKHZiKaXLorx0N-lNg-pNh8nOihDnibTJo42Tnx7D0FTnShB1wfVUZ9XmU5kikye8iCRccl5GbIk3MX2uQJAWCdx8g02jmq7-e6dNDJYPDW5-Q/w640-h258/Dynamic+YoY.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;"><span style="font-family: arial;">So much of the basics, now let's look at expanding the model at creating a rolling YoY using the approach. To keep the visual simple I have expanded the date to quarterly level data and compressed the categories so we are looking at totals only</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">For the current and prior year rolling totals I used a table calculation</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">Current year:</span></div><p></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p></p><div class="separator" style="clear: both;"><span style="font-family: arial;"><b>window_sum(sum([Sales]),-3,0)</b></span></div><p></p></blockquote><p></p><p><span style="font-family: arial;">and Prior year</span></p><p></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p></p><p><span style="font-family: arial;"><b>window_sum(sum([Sales Prior Year]),-3,0) </b></span></p><p></p></blockquote><p><span style="font-family: arial;">They result in this:</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg69omhE4qSgtkrCHzxLete_AzkM_UeOknTEEPjpnfNNvqVKoSk3MQ5SXM8tyb9UF6b84VCMbKIYfQS9ASeQkBIDQ7fnjoUT67aanc1ml3-QgYJ7KhFLBGxflu-QnpKQunC0IhyvptIJzg/s1051/4q+rolling+compare.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="606" data-original-width="1051" height="370" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg69omhE4qSgtkrCHzxLete_AzkM_UeOknTEEPjpnfNNvqVKoSk3MQ5SXM8tyb9UF6b84VCMbKIYfQS9ASeQkBIDQ7fnjoUT67aanc1ml3-QgYJ7KhFLBGxflu-QnpKQunC0IhyvptIJzg/w640-h370/4q+rolling+compare.png" width="640" /></a></div><br /> </div><div><b><span style="font-family: arial;">5 Using a scaffold to fill the nulls</span></b><br /><p></p><p><span style="font-family: arial;">But there is a problem when the data is sparse - where there are nulls or voids in the data. </span></p><p><span style="font-family: arial;">I expanded the dataset to the Month and day level and that introduced voids in the data</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisIRcXXKULBK9W6uXsEBWQYbHccyR0Diu1lAxuotaYvE8aubEZ5ZL-XEeQFmK9Nr1CWnuOEWHFVjeNbHiIM1PYwiySRnlRyNXSg7K2qobL75GUfuSyxXzd6TBtKUHMpGosTkwxwshUJVE/s896/joined+with+voids.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="700" data-original-width="896" height="500" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisIRcXXKULBK9W6uXsEBWQYbHccyR0Diu1lAxuotaYvE8aubEZ5ZL-XEeQFmK9Nr1CWnuOEWHFVjeNbHiIM1PYwiySRnlRyNXSg7K2qobL75GUfuSyxXzd6TBtKUHMpGosTkwxwshUJVE/w640-h500/joined+with+voids.png" width="640" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">The prior year data will no longer total properly due to the nulls in the data </span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEichz1fARFfC5KRyaNYtZVNMm1vmr2tg5pUFgfVw64pGoiOjkMpp1bR8ibJDRdFnEyMxMMW8mTFcSpZm3sa9BMaQWg0Y207Y_ShpBuARhCi88hJkelJV5_pdifKw6M9dMJYcDsYplaDjZs/s677/nulls+in+the+total+yoy.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="468" data-original-width="677" height="442" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEichz1fARFfC5KRyaNYtZVNMm1vmr2tg5pUFgfVw64pGoiOjkMpp1bR8ibJDRdFnEyMxMMW8mTFcSpZm3sa9BMaQWg0Y207Y_ShpBuARhCi88hJkelJV5_pdifKw6M9dMJYcDsYplaDjZs/w640-h442/nulls+in+the+total+yoy.png" width="640" /></a></div><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">To correct the problem requires first creating the missing cells. That is done by scaffolding the data - I used Prep to create a ladder at the date/category level and joining it back to the original data</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4SimOVIzZVdM5diUTlI0b9dDyYojDFbgJSTxd5bT-Osu0wuxaW44RbaAyZeDbX7sdJFsXWx9mRWy6vRtGwKTIiTmQcT1UzWRcgyFDbBX_es5k-qggCIWGZZqKJiLS9XzXa0P-tpx1Uig/s1920/Prep+exploded+file.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4SimOVIzZVdM5diUTlI0b9dDyYojDFbgJSTxd5bT-Osu0wuxaW44RbaAyZeDbX7sdJFsXWx9mRWy6vRtGwKTIiTmQcT1UzWRcgyFDbBX_es5k-qggCIWGZZqKJiLS9XzXa0P-tpx1Uig/w640-h360/Prep+exploded+file.png" width="640" /></a></div><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">resolving the nulls and the prior year now totals correctly</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJW2pV29Lod9Q6Fq3KZEbnMK48fLv29vfWYBGbn8DW7OZfsHSuJT9nZDSTilRHDH49jpBnAanlHE229BQ5TBYAK2rQoS5Owxin7VOrGID0Niq4SZhU63LmaQHCH4-l72R1IlhW_U_fugQ/s600/properly+joined+results.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="499" data-original-width="600" height="532" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJW2pV29Lod9Q6Fq3KZEbnMK48fLv29vfWYBGbn8DW7OZfsHSuJT9nZDSTilRHDH49jpBnAanlHE229BQ5TBYAK2rQoS5Owxin7VOrGID0Niq4SZhU63LmaQHCH4-l72R1IlhW_U_fugQ/w640-h532/properly+joined+results.png" width="640" /></a></div><p><br /></p><span style="font-family: arial;">I hope this helps the next time you need to do a YoY analysis and helps select the best method to use in your situation</span><p></p><p><span style="font-family: arial;">The workbook use here can be downloaded at :<a href="https://public.tableau.com/app/profile/jim.dehner/viz/5Ways-YoYandYTD/Titleslide" target="_blank">Link to workbook</a></span></p><p><br /></p><p><span style="font-family: arial;">Jim<br /></span></p></div>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-27015519458883841702021-05-26T09:32:00.001-05:002022-01-24T08:52:29.285-06:00Zero to Zen and 5 Stops Along The Way<p> </p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Zero to Zen covers the 5 foundational concepts I needed to learn on the journey from spreadsheets to Tableau</span></p><p><span style="font-family: arial;">Like many, I struggled when first introduced to Tableau 5 years ago. I don't come from a data scientist background. - Actually I'm and engineer, very analytic and expert level spread sheet skills but I just didn't get it at first.</span></p><p><span style="font-family: arial;">Looking back there were 5 concepts that I needed to understand which were not at all like spreadsheets before I was comfortable working in Tableau. Over a 5 week series I shared those lessons learned - Below are brief summaries of each and links to the recordings and the workbook used in each session. </span></p><p><span style="font-family: arial;">Hope you enjoy</span></p><p><span style="font-family: arial;">Jim</span></p><p><span style="font-family: arial;"><b>Session 1 - Data Structure and Connections </b></span></p><p><span style="font-family: arial;">Three types of connections, Joins, Unions and Blending and the limitations of each were covered. Also reviewed were several how to use cases include why it is sometimes necessary to use scaffolding to restructure the data set </span></p><p><span style="font-family: arial;">Session recording can be found at: </span><a href="https://www.youtube.com/watch?v=3xhTUmNl3Q4&list=PL_qx68DwhYA_-2lTeTpzvb7abRVy_Ufss&index=1" style="font-family: arial;" target="_blank">Session 1 Recording</a></p><p><span style="font-family: arial;">The session workbook can be downloaded at: <a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/ZerotoZen-Session1-DataStructureandConnections/Openslide" target="_blank">Session 1 Workbook</a> </span></p><p><br /></p><p><b style="font-family: arial;">Session 2 - Order of Operation </b></p><p><b style="font-family: arial;"><br /></b></p><p><span style="font-family: arial;">Misuse of the Order of Operation is the usual cause when users get unexpected results in their analysis. It is the sequence that Tableau goes through to first create the data table for each worksheet ( That's right - each worksheet has its own individual data table that is a subset of the full data set uploaded into Tableau). Once the structure of the data table is established, values are loaded, calculations performed, and the visual presentation created. Frequent areas of error are misapplication of context filter, trying to filter across blended data sources, and attempting to "fix" table calculations for use on other sheets </span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Session recording can be found at: <a href="https://www.youtube.com/watch?v=wYe2ZWs8XzA&list=PL_qx68DwhYA_-2lTeTpzvb7abRVy_Ufss&index=2" target="_blank">Session 2 Recording</a></span></p><p><span style="font-family: arial;">The session workbook can be downloaded at: <a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/OrderofOperations_1220/startslide" target="_blank">Session 2 Workbook</a> </span></p><p><span style="font-family: arial;"><br /></span></p><p><b style="font-family: arial;">Session 3 - Simple Calculations and Date Functions</b></p><p><b style="font-family: arial;"><br /></b></p><p><span style="font-family: arial;">This first of 2 sessions on calculations covers the use of the Calculation Wizard, using aggregations to do simple math calculations, If - Then conditional statement and date functions. Dates are a special data type in Tableau which self sequence, sort and allow the use of the 4 types Date Functions - those which return dates, refer to dates, are used in date math, and the 2 special Today() and Now(). Use case show how dates are treated as discrete or continuous or can still be continuous yet presented as discrete</span></p><p><span style="font-family: arial;">Session recording can be found at: <a href="https://www.youtube.com/watch?v=QMRepiruVj0&list=PL_qx68DwhYA_-2lTeTpzvb7abRVy_Ufss&index=3" target="_blank">Session 3 Recording</a></span></p><p><span style="font-family: arial;">The session workbook can be downloaded at: <a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/ZerotoZenSession3-CalculationsI/titleslide" target="_blank">Session 3 Workbook</a> </span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;"> </span><b style="font-family: arial;">Session 4 - LOD Expressions and Table Calculations</b></p><p><b style="font-family: arial;"><br /></b></p><p><span style="font-family: arial;">My favorite, LOD expressions provide versatility by allowing the user to create layers in the data set and then use the layer like any other measure in calculations, nested in other LOD's or in table calculations. Table calculations are last in the order of operation and are executed on the data table for the specific worksheet making the unique the sheet where they are applied. Use cases reviewed nesting LOD's in table calculations, nesting table calculations, totally Top N and Other and the use of Show Hide filters</span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Session recording can be found at: <a href="https://www.youtube.com/watch?v=EDJ-vFVZYkY&list=PL_qx68DwhYA_-2lTeTpzvb7abRVy_Ufss&index=4" target="_blank">Session 4 Recording</a></span></p><p><span style="font-family: arial;">The session workbook can be downloaded at: <a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/ZerotoZenSession4-LODexpressionsandTableCalculations/startslide" target="_blank">Session 4 Workbook</a></span></p><p><br /></p><p><span style="font-family: arial;"> </span><b style="font-family: arial;">Session 5 - Filters, Sets and Parameters </b></p><p><b style="font-family: arial;"><br /></b></p><p><span style="font-family: arial;">Filters, sets and parameters are the user interface to the viz, allowing users to probe and drill into the data and gain meaning and understanding. Filters remove data and change the structure of the data table for the worksheet, sets retain all the data in the data table but categorized it into the In and the Out sets and finally parameters are the other way users can input a single, static value into Tableau. Over the series a number of seemingly fundamental concept were introduced or review yet in combination those basic idea can be used to create any more complex visualization -</span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Session recording can be found at: <a href="https://www.youtube.com/watch?v=vRG56BFkiK8&list=PL_qx68DwhYA_-2lTeTpzvb7abRVy_Ufss&index=5" target="_blank">Session 5 Recording</a></span></p><p><span style="font-family: arial;">The session workbook can be downloaded at: <a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/BuildDBpresentationupload/TitleSlide" target="_blank">Session 5 Workbook</a></span></p><p><br /></p><p><span style="font-family: arial;">Feel free to download and use the recordings and workbook or any other material on my blog or Public Profile - that's why it is there</span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Jim</span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;"><br /></span></p>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-55032264347630546732021-02-19T15:08:00.004-06:002022-01-24T07:39:10.093-06:00FAQ Series - When and How to Scaffold Data<p> </p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Data structure has a huge affect on the results you get from your analysis. </span><span style="font-family: arial;">Like most of you, I trained using well structured and full data sets - where there was a value in every record (cell) - like a tightly fit puzzle - (Note - Presented that the Atlanta TUG in Sept 2021 - see the recording at <a href="https://youtu.be/yr-gPHUe26w?list=PL_qx68DwhYA_5dpAyzqebVnvA2_h-Lfh-&t=3531">Video link</a> )</span></p><p><span style="font-family: arial;"> </span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7ZXa22279mS-krRyeJNMFzDUyp5gbsv-DaCuHs9bSLXGyi9AbBMiwuAFSOCmQmqmG-n0XPagwOEen4FlMSpCKuz6W0gOkcoPlnngdtdcHhsIGlS7ooNCEevYiVvl5Uq_dKBukDkgOZOo/s965/tight+puzzle.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="548" data-original-width="965" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7ZXa22279mS-krRyeJNMFzDUyp5gbsv-DaCuHs9bSLXGyi9AbBMiwuAFSOCmQmqmG-n0XPagwOEen4FlMSpCKuz6W0gOkcoPlnngdtdcHhsIGlS7ooNCEevYiVvl5Uq_dKBukDkgOZOo/s320/tight+puzzle.png" width="320" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">With real world data that is often not the case. Data can come from ERP systems, stand alone third party or public sources and contains voids or is sparse or otherwise badly structured resulting in gaps in the data.</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI7FfkuNgij3Wrx2cO6-KIOKOfHXBH1MG_NoCz9TKBCFx6mkjH-cRyTu9FKhoQz0tuUcD1o0xlsMPr-FlM4eX6h2z_7x9F6S-q8GIhtbr7EbZlwjYjPs68Gru8_G8R3bRjiX7tihM9G58/s556/gap+puzzle.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="556" data-original-width="490" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI7FfkuNgij3Wrx2cO6-KIOKOfHXBH1MG_NoCz9TKBCFx6mkjH-cRyTu9FKhoQz0tuUcD1o0xlsMPr-FlM4eX6h2z_7x9F6S-q8GIhtbr7EbZlwjYjPs68Gru8_G8R3bRjiX7tihM9G58/s320/gap+puzzle.png" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">Scaffolding is one way to re-structure the data and fill the gaps. </span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">We are going to look at 3 different frequently encountered use case where data needs to be scaffolded to solve the problem. The cases are adapted from actual questions that were posted on the Forum - data and names changed</span></p><p><span style="font-family: arial;"> </span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVW6or3vFpOcJKpxPyddGoXbF-WgaemILi6yeMZ7xkjYTSslZqTRbEtPlsUVcSm61syA9NEJGD2W8RPur9SCkxotoAXox-rMqx0IgR3V80VC3hJreZIeZQhImxN-IZgRSfgwgwpxEjnUU/s816/Use+case+header.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="633" data-original-width="816" height="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVW6or3vFpOcJKpxPyddGoXbF-WgaemILi6yeMZ7xkjYTSslZqTRbEtPlsUVcSm61syA9NEJGD2W8RPur9SCkxotoAXox-rMqx0IgR3V80VC3hJreZIeZQhImxN-IZgRSfgwgwpxEjnUU/w400-h310/Use+case+header.PNG" width="400" /></a></span></div><span style="font-family: arial;"><br /><div class="separator" style="clear: both; text-align: center;"><br /></div></span><p></p><span style="font-family: arial;"><br /></span><p></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p></p><div class="separator" style="clear: both;"><b style="font-family: arial;"><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq8QRJtarb0MdOE3zIQFYG4p9kdxIi1xKXA6ZcoRm6QXoeySl-hcgOH9mMCCGIQ8_L-fw_3yZRSNwvP5PXQYievs9t8allkvLh3p9KjKojFnJ8-dgrPIrbyJQipspb2cYI1VUDe_l8WxI/s556/gap+puzzle.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="556" data-original-width="490" height="58" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq8QRJtarb0MdOE3zIQFYG4p9kdxIi1xKXA6ZcoRm6QXoeySl-hcgOH9mMCCGIQ8_L-fw_3yZRSNwvP5PXQYievs9t8allkvLh3p9KjKojFnJ8-dgrPIrbyJQipspb2cYI1VUDe_l8WxI/w51-h58/gap+puzzle.png" width="51" /></a></div><br />1 - The 2 Date Problem</b></div><p></p></blockquote><p><span style="font-family: arial;"><b> </b></span></p><p><span style="font-family: arial;">The '2 Date Problem' is a classic case - each record in the data has a start date and end date and you need to look at all the periods in between. It comes up when you need to count the active programs, total cash flow over a series of mortgages or annuities, or, as in this example count head count over time.</span></p><p><span style="font-family: arial;">The question came from an HR manager who had a number of open positions. Each had an "open date", some had been filled and others were still open. The manager wanted to count all the open positions and separately those filled by month. </span></p><p><span style="font-family: arial;">The data looked like this:</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWeU7SXl0vSiWmQRancqoV0qJX7M0gyefOCT0TFL8vtHrRv1Ucl3s-tI0esguOKrBEfBjTp6wtPReSQDHXtykBZ3GTcDcqvp8DmzOD9YPNvlcE3NLrikET0ShyphenhyphenT8RZiwenaOiAKO4lDuc/s776/2+date+raw+data.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="412" data-original-width="776" height="341" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWeU7SXl0vSiWmQRancqoV0qJX7M0gyefOCT0TFL8vtHrRv1Ucl3s-tI0esguOKrBEfBjTp6wtPReSQDHXtykBZ3GTcDcqvp8DmzOD9YPNvlcE3NLrikET0ShyphenhyphenT8RZiwenaOiAKO4lDuc/w640-h341/2+date+raw+data.PNG" width="640" /></a></span></div><span style="font-family: arial;"><br /> </span><p></p><p><span style="font-family: arial;">Each requisition had start and end dates as independent values but there was no calendar common to every record. The solution was to build a calendar using a scaffold. In this case, the manager was only interested in monthly totals so a monthly date ladder would suffice: </span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVv8I3yiDh1zCGyRu1mK-whwo9GmGLDOON4kG9edfykR51JPv3xS2Y-x1KsoeYctORmmn55woG5Mg_35d1D6quLwby7w-5ADFmoIA5H46cU50Lgn_DIuJ1A4fIMJXJzftwa9NhHCnaRAs/s361/2+date+date+scaffold.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="361" data-original-width="312" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVv8I3yiDh1zCGyRu1mK-whwo9GmGLDOON4kG9edfykR51JPv3xS2Y-x1KsoeYctORmmn55woG5Mg_35d1D6quLwby7w-5ADFmoIA5H46cU50Lgn_DIuJ1A4fIMJXJzftwa9NhHCnaRAs/w346-h400/2+date+date+scaffold.PNG" width="346" /></a></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">The scaffold and the base data were joined so that every record in the base data was connected to each record in the scaffold - a "Cartesian join" - with a 1=1 join clause<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-b0GyjzWCAhrPgaBGQrUzSz0MofXzl_lr8kFWD8YaxkHuCHDyRH6jI_Z9p4bRiRbIIpEExvIzlf-Li3RKSLsGEjsun1hYDMBDpqZkWvDSC-a2S0ZIMT_qdyjIZsrAtWcCC_e-DJ82ffc/s582/2+date+join.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="312" data-original-width="582" height="215" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-b0GyjzWCAhrPgaBGQrUzSz0MofXzl_lr8kFWD8YaxkHuCHDyRH6jI_Z9p4bRiRbIIpEExvIzlf-Li3RKSLsGEjsun1hYDMBDpqZkWvDSC-a2S0ZIMT_qdyjIZsrAtWcCC_e-DJ82ffc/w400-h215/2+date+join.PNG" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /></span></div><span style="font-family: arial;">Using the scaffold date resulted in a calendar that included each job requisition</span><div><span style="font-family: arial;"><br /></span><span style="font-family: arial;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrVei2K1qOS6WuBquAr7PH_jSL3i74anlbKCZgZm_G3wKckmc_AY7xRhGDe1E9_XYc0uzqSO4mNRt3tEGsCKEP4P9LZOXf-ej8G41JgZUU8HVrzH78iqUeM0umprc0PWZY6VZ33Oifrog/s1233/2+date+calendar+view.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="599" data-original-width="1233" height="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrVei2K1qOS6WuBquAr7PH_jSL3i74anlbKCZgZm_G3wKckmc_AY7xRhGDe1E9_XYc0uzqSO4mNRt3tEGsCKEP4P9LZOXf-ej8G41JgZUU8HVrzH78iqUeM0umprc0PWZY6VZ33Oifrog/w640-h310/2+date+calendar+view.PNG" width="640" /></a></div><br /></span><p></p><p><span style="font-family: arial;">All that was need were 2 LOD expressions to count the filled or open jobs by month</span></p><p><span style="font-family: arial;">the filled LOD is </span></p><p><span style="font-family: arial;"><br /></span></p><p align="center" class="MsoNormal" style="margin-bottom: 0in; text-align: center;"><span style="font-size: 12pt; line-height: 17.12px;"><span style="font-family: arial;">{ FIXED [Job Ref ID1] , [Scaffold Date]: countd( if not ISNULL([Job open date]) </span></span></p><p align="center" class="MsoNormal" style="margin-bottom: 0in; text-align: center;"><span style="font-size: 12pt; line-height: 17.12px;"><span style="font-family: arial;">and </span></span><span style="font-family: arial; font-size: 12pt;">DATETRUNC('month',[Job filled date])=DATETRUNC('month',[Scaffold Date])</span></p><p align="center" class="MsoNormal" style="margin-bottom: 0in; text-align: center;"><span style="font-family: arial; font-size: 12pt;">then [Job Ref ID1]</span><span style="font-family: arial; font-size: 12pt;"> </span><span style="font-family: arial; font-size: 12pt;">end )}</span></p><p><br /></p><p><span style="font-family: arial;">and the open LOD is </span></p><p style="text-align: center;"><span style="font-family: arial;">{ FIXED [Job Ref ID1] , [Scaffold Date]: countd( </span></p><p style="text-align: center;"><span style="font-family: arial;">if DATETRUNC('month',[Job open date])<= DATETRUNC('month',[Scaffold Date]) </span></p><p style="text-align: center;"><span style="font-family: arial;">and ( DATETRUNC('month',[Job filled date])>DATETRUNC('month',[Scaffold Date])</span></p><p><span style="font-family: arial;"></span></p><p style="text-align: center;"><span style="font-family: arial;">or ISNULL([Job filled date]))then [Job Ref ID1] end )}</span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">and the result looked like this</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIKOLQBmMjarVyB8o5vMWG3sEB8gt67aaRMOHGH4I3dycf8tp9RNgx00J9BrFYM4qIF-tTbtmvK3fY7f_g1I7XTtU47O8oCHcRRZgSlhWrgt5mzT5uPWSg_YV7lxjSwg7P1f5HEpezdLw/s863/Capture.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="863" data-original-width="804" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIKOLQBmMjarVyB8o5vMWG3sEB8gt67aaRMOHGH4I3dycf8tp9RNgx00J9BrFYM4qIF-tTbtmvK3fY7f_g1I7XTtU47O8oCHcRRZgSlhWrgt5mzT5uPWSg_YV7lxjSwg7P1f5HEpezdLw/w373-h400/Capture.PNG" width="373" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;"><span style="font-family: arial;">By using the date scaffold to create a calendar, the solution was reduced to just checking each month to see which positions were still open and which had been filled.</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><b>2 When drilling down breaks the analysis</b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><b><br /></b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">Data that appear to be solid a high levels of aggregation can be sparse or have voids when drilling down a dimension hierarchy or to lower date levels. The problem is common with data that comes from ERP systems (like Oracle or SAP). ERP systems are transaction driven and only create a record when a transaction takes place e.g. if there are no sales for a particular SKU on a date there is no record in the data set. </span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">To illustrate the issue we will look at an inventory analysis where a production planner wanted to calculate a very common metric used as an indicator that inventory levels were either too high or low. </span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">For those not familiar with EPR systems and the forecasting to production process, a quick review. The ERP system records sales directly from the sales invoice. That data is precise - we know the customer, the date, the SKU (stock keeping unit), the unit quantity and the dollar value. The data can then be aggregate along several different hierarchies - here along the product and is still very accurate although somewhat less useful <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwTfbIrGmzS9Mk9zeXpfC0BwxLsRF6pcv7St-TqAxcyh47XP3LS43SQfWmlouTRfC0tYlpVVKvlaHsxmJM1n7wTZ_681NdqEwTKKE9CNrBYhq8Fex0Ja_7FYw3u-DSuMecLRD8-twLQKY/s1388/erp+sys+1a.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="783" data-original-width="1388" height="362" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwTfbIrGmzS9Mk9zeXpfC0BwxLsRF6pcv7St-TqAxcyh47XP3LS43SQfWmlouTRfC0tYlpVVKvlaHsxmJM1n7wTZ_681NdqEwTKKE9CNrBYhq8Fex0Ja_7FYw3u-DSuMecLRD8-twLQKY/w640-h362/erp+sys+1a.PNG" width="640" /></a></div><br /></span></div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><br /></div><br /><span style="font-family: arial;">Forecasters and product managers will use the sales history to create a rolling forecast that is used by the production planning and purchasing departments to develop the production schedule. The process starts at the top on the pyramid and works downs, each level being a lower level of aggregation that is more useful to the planner but less accurate than the preceding </span><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9oCSHmmuqeTf4B0sfwsouaR2fMT8SrMqdt5ITVPNfaHFoxrixTymfia461vbdUyiyxncdx8UKClY6YlKqPXYojl7YrpbMI_acqtGt1QPjLO1c-hzODQoDv6B4pNAXOS3iXGK4GlVwu_M/s1386/forecast+and+planning+1a.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="774" data-original-width="1386" height="358" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9oCSHmmuqeTf4B0sfwsouaR2fMT8SrMqdt5ITVPNfaHFoxrixTymfia461vbdUyiyxncdx8UKClY6YlKqPXYojl7YrpbMI_acqtGt1QPjLO1c-hzODQoDv6B4pNAXOS3iXGK4GlVwu_M/w640-h358/forecast+and+planning+1a.PNG" width="640" /></a></div><br /><span style="font-family: arial;">Forecast are usually adjusted monthly along a 3 or 4 month forecasting horizon. The production schedulers take the lowest level -Units by SKU by week and schedule production, purchase components, and plan inventory levels. While the forecasting and planning process are numbers in the system and the results become less accurate at lower levels in the pyramid, actual production and inventory levels are precise. You know exactly how many units were produced for each SKU and the inventory levels. </span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">With the uncertainties in the process, planners track a metric as an early warning when the forecast is too high or the inventory too low so they can adjust the production schedule. The metric is Days on Hand (or days Sales, or just Days). The calculation is just </span></div><div><span style="font-family: arial;"><br /></span></div><div style="text-align: center;"><span style="font-family: arial;"><b>Sum(Inventory level) / Average daily sales</b></span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">That is where the user question fits in. He was an production planner manager and was planning a single item, had 4 customers to consider and was pulling sales, inventory and production data from their ERP system. The data looked something like this with a separate file for each customer:</span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAfXHr4v9-A6KcOtsUSglj0zJBRAEALzzm6W1TNKPhBBrNdioAqKUMC341H9nE8eSC7Gwjts_lLnHHVV7N-vuomtHsydOOH6SncZGVqAe3BZxqi4VM7Pou_CxujBeb60EuzSSN_HHdm5g/s561/inventory+raw+excel.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="502" data-original-width="561" height="358" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAfXHr4v9-A6KcOtsUSglj0zJBRAEALzzm6W1TNKPhBBrNdioAqKUMC341H9nE8eSC7Gwjts_lLnHHVV7N-vuomtHsydOOH6SncZGVqAe3BZxqi4VM7Pou_CxujBeb60EuzSSN_HHdm5g/w400-h358/inventory+raw+excel.PNG" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">He was getting different Days on Hand results that could not be reconciled for individual customers or across the group as a whole.</span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">After filtering the results to show only the last date and they looked something like this across all 4 companies:</span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvoUXNKfcOYWLxUTp6B7oT6Cu8fTKkEpwmbk4TYOQvQ3Le0sGMwhVSmKOy6V6HnTQ3GcePKf5GNyuE40aY16UCvQJoyPgmVhdR6li5UfR2Tty_yg2jm2ANcwmrDYkzmHZJT0nIDG8rNWs/s1920/Inventory+incorrect+results+total.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvoUXNKfcOYWLxUTp6B7oT6Cu8fTKkEpwmbk4TYOQvQ3Le0sGMwhVSmKOy6V6HnTQ3GcePKf5GNyuE40aY16UCvQJoyPgmVhdR6li5UfR2Tty_yg2jm2ANcwmrDYkzmHZJT0nIDG8rNWs/w640-h360/Inventory+incorrect+results+total.png" width="640" /></a></div><br /><span style="font-family: arial;">But some results look odd</span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhheEoQtj6ChfZD53qiUZXjqYYvZmZSv3LfjBvZUZdiLRYZKXoEM74l1XPbkOznnrl4k44CCj2uFWOl4LeM0cOqc04qTvA5Dn_9w8pxM-h-9y9Y_NklcGDJTWUkrn3YqOkzFEyfLR5q2xI/s950/inventory+close+up+incorrect+results.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="571" data-original-width="950" height="384" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhheEoQtj6ChfZD53qiUZXjqYYvZmZSv3LfjBvZUZdiLRYZKXoEM74l1XPbkOznnrl4k44CCj2uFWOl4LeM0cOqc04qTvA5Dn_9w8pxM-h-9y9Y_NklcGDJTWUkrn3YqOkzFEyfLR5q2xI/w640-h384/inventory+close+up+incorrect+results.PNG" width="640" /></a></div><div><span style="font-family: arial;"><br /></span></div><span style="font-family: arial;">So lets see what is going on:</span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">First the formula for the Seven Day Avg Sales is <b>window_avg(sum([Sales]),-6,0)<br /></b>and that is a clue to the first problem - Window average is a table calculation that looks at the last 7 records, not days but </span><span style="font-family: arial;">this is what the actual data looked like when all the records were visible </span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvBvpn9ahTCWOehWFlzWpvYKO0Wn5TUvxH6O7rsZHYKJ0Mhi9rpJFzfXxgHejcbNFlwgf2f6f_mriqbJo-xCj0Wwh17FIRPRIgL6f2nN8XNy7_4JENms-mjd0BP8c8raHNEU_G_bQGbOk/s976/inventory+last+7+days+sparse+data.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="799" data-original-width="976" height="328" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvBvpn9ahTCWOehWFlzWpvYKO0Wn5TUvxH6O7rsZHYKJ0Mhi9rpJFzfXxgHejcbNFlwgf2f6f_mriqbJo-xCj0Wwh17FIRPRIgL6f2nN8XNy7_4JENms-mjd0BP8c8raHNEU_G_bQGbOk/w400-h328/inventory+last+7+days+sparse+data.PNG" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><span style="font-family: arial;">Many Nulls - very sparse data and it is clear that for Customer D there was only 1 sale in the final 7 days and that was for 1000 units so the average did not take into account the nulls. The nulls in the data were "no record null" see <a href="https://jimdehner2.blogspot.com/2020/01/faq-series-not-all-nulls-are-created.html" target="_blank">Null Types</a> and a scaffold is needed to be used to force a record into the data for each combination of customer name and date.</span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">Tableau Prep was used to force the record into the data - the first step joins the customer list to the date list (Cartesian)</span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA-w3sik-jtDXDD3PL_46fYnWygXnIpRXMjan5PffUHTwvcLkzA53utnfo7lYgtD5ntFsjR7YLGIO5NSMVup40MYXaggLibjEbQT4ZknF49Pyml8CWHd89bi_45-2JDQrA4DhedMDzIVQ/s1879/Inv+Prep+1.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="943" data-original-width="1879" height="322" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA-w3sik-jtDXDD3PL_46fYnWygXnIpRXMjan5PffUHTwvcLkzA53utnfo7lYgtD5ntFsjR7YLGIO5NSMVup40MYXaggLibjEbQT4ZknF49Pyml8CWHd89bi_45-2JDQrA4DhedMDzIVQ/w640-h322/Inv+Prep+1.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;"><span style="font-family: arial;">The second joins the original data to the ladder </span></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1jpqsyreGdBzkbZZKFKqiRlF8EqGTulu3EmHPEokqcIPEXPkm6-Vm4UUZxq9S6Px40_KPZOZJdHetk5v_ZjGah9jDXoIkmW3Zjtgjt6qor6agaBrs-crqAwt62y5gX8W2XgZKiGmx2EY/s1867/Inv+Prep+2.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="951" data-original-width="1867" height="326" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1jpqsyreGdBzkbZZKFKqiRlF8EqGTulu3EmHPEokqcIPEXPkm6-Vm4UUZxq9S6Px40_KPZOZJdHetk5v_ZjGah9jDXoIkmW3Zjtgjt6qor6agaBrs-crqAwt62y5gX8W2XgZKiGmx2EY/w640-h326/Inv+Prep+2.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><span style="font-family: arial;">after scaffolding the last seven data data looks like this ( note zn() functions and previous applied ) - and the data now runs through the end of February</span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9J6dcZ159YpirpB_HCQ9cWC1JBlYWAePORdRHTJ_36KoD-FNGPRjAGiP6ds7Ne-jcJaokJuz5dI7WoiSMQmATdXP-2F2Y7XWIR1XrH1Fr77fykHqr4o_knxna2LLgahxrbnea7AwpOkY/s1016/inventory+scaffolded+last+7+days.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="817" data-original-width="1016" height="514" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9J6dcZ159YpirpB_HCQ9cWC1JBlYWAePORdRHTJ_36KoD-FNGPRjAGiP6ds7Ne-jcJaokJuz5dI7WoiSMQmATdXP-2F2Y7XWIR1XrH1Fr77fykHqr4o_knxna2LLgahxrbnea7AwpOkY/w640-h514/inventory+scaffolded+last+7+days.PNG" width="640" /></a></div><br /><span style="font-family: arial;">and the last day summary across the 4 companies is</span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJJBqBWjuGc5OGGMg3NrVsZH-p_XMNhIfxg7ZwDGsnBr-fJWGyMNhPsHdyJ9A0V9UhZbU7FVDofYVFGv_goH5KGlcAw62n6cIHpK7Zda2tTWUp0gPhiZ2nDwl4ncZphNZrchhn79PjTu0/s830/inventory+4+company+last+day+totals.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="288" data-original-width="830" height="222" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJJBqBWjuGc5OGGMg3NrVsZH-p_XMNhIfxg7ZwDGsnBr-fJWGyMNhPsHdyJ9A0V9UhZbU7FVDofYVFGv_goH5KGlcAw62n6cIHpK7Zda2tTWUp0gPhiZ2nDwl4ncZphNZrchhn79PjTu0/w640-h222/inventory+4+company+last+day+totals.PNG" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><br /></span></div><span style="font-family: arial;">The actual Days on Hand when the missing data has been include is very different than the original results. This is a case where the planner (the Subject Matter Expert) would not know what the data structure looks like nor should he - that is the role of the dashboard designer and data scientist - It is also a by product of the data source - the ERP system that could affect your next analysis</span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;"><b>3 Voids in the data</b></span></div><div><span style="font-family: arial;"><b><br /></b></span></div><div><span style="font-family: arial;">Voids, single or small groups of no records nulls in the data, will return a null (blank screen) if the unsuspecting user filters to that combination of dimensions. <br /></span></div><div><span style="font-family: arial;">The user had created a viz using small multiples - a great way to see the changes across all values of a dimension in a single view - here using Superstore data (note there are 17 images one for each sub-category in the data set)</span></div><div><span style="font-family: arial;"><br /></span><span style="font-family: arial;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjjHLpmrIFfw45kd7pJVVtvXci_rJ92BP32q5z-KPafpcCFLC3Vo0Jr-r3d2kCGyRhy69yyoemRXBgU5MYfJW6cJg87EI9_pip5faCyk2bphb1P_mprAQhFR_m9OZKtwIyQuao4lQnPps/s1920/small+multi+problem+def+1.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjjHLpmrIFfw45kd7pJVVtvXci_rJ92BP32q5z-KPafpcCFLC3Vo0Jr-r3d2kCGyRhy69yyoemRXBgU5MYfJW6cJg87EI9_pip5faCyk2bphb1P_mprAQhFR_m9OZKtwIyQuao4lQnPps/w640-h360/small+multi+problem+def+1.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div>When the date is filtered to on February 2016, 4 images disappeared (returned a null) </span></div><div><span style="font-family: arial;"><br /></span><span style="font-family: arial;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgb-xlByGntDweF-lwHs0JMTKaI635s3VMbnX4xv3yHxi3xPVtG8X6RM5oZEX9EJK9K6L7alQ5d0uu9zeqjUn2YI8jGS4_AlUMCgti2B5-jADYiS5yCVDhqLhtlACTiLB6LxYMb3_P3cs/s1920/small+multi+prob+def+2.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgb-xlByGntDweF-lwHs0JMTKaI635s3VMbnX4xv3yHxi3xPVtG8X6RM5oZEX9EJK9K6L7alQ5d0uu9zeqjUn2YI8jGS4_AlUMCgti2B5-jADYiS5yCVDhqLhtlACTiLB6LxYMb3_P3cs/w640-h360/small+multi+prob+def+2.png" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div>The user had 2 questions - Why did it happen and then how to correct the problem</span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">When the user filtered to February there are no records in 4 subcategories - the voids returned Nulls causes the 4 image to "disappear"</span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwMHT5zRX39oqllhqnLOiOo8SNuAKkPHBuVxBBiJ7ufDBvSMDcMTrr4OMt3bE6ss3EQg6teQipNDJYrv8JaxC9uxNcgLdNjd0ZNezR-a-hLMl28EhDQiIpxynME38Wihn2ZqSidg-7Akg/s925/small+multi+text+voids.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="677" data-original-width="925" height="469" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwMHT5zRX39oqllhqnLOiOo8SNuAKkPHBuVxBBiJ7ufDBvSMDcMTrr4OMt3bE6ss3EQg6teQipNDJYrv8JaxC9uxNcgLdNjd0ZNezR-a-hLMl28EhDQiIpxynME38Wihn2ZqSidg-7Akg/w640-h469/small+multi+text+voids.PNG" width="640" /></a></div><br /></span></div><div><span style="font-family: arial;"> Here using a scaffold to force a record into each void will solve the problem. </span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">I used Tableau Prep to create the scaffold. First Cartesian join the date and subcategory fields</span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP5cH7q5lmTFTgniut7avjAaZZ_rzuQONyQegkItWYB_1ZxSeGJszwx9BEcqhyKna_BAriQMGIpJScemLrsFtXI0JLhgy1Oh3u2GHlPtvpW-1uh5lLHl4fKHXwMq4tEocRjhsBB3xJqZs/s1874/Small+Multi+Prep+1.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="957" data-original-width="1874" height="326" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP5cH7q5lmTFTgniut7avjAaZZ_rzuQONyQegkItWYB_1ZxSeGJszwx9BEcqhyKna_BAriQMGIpJScemLrsFtXI0JLhgy1Oh3u2GHlPtvpW-1uh5lLHl4fKHXwMq4tEocRjhsBB3xJqZs/w640-h326/Small+Multi+Prep+1.PNG" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;"><span style="font-family: arial;">Then connect that to the Superstore dataset</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0qUGex3OrDm-we6kiqm8-59XypKZQjs0rVbt9Ut_Ke2u1oGENIlzy6NdvoyQzvZE_h5XrHL1Rbm78cfHvWz-tO4YtO4JwygOZvMLIwbJgmrynyS78dnUIjuldy2acrun0svNUV6r0YOc/s1878/Small+Multi+Prep+2.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="911" data-original-width="1878" height="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0qUGex3OrDm-we6kiqm8-59XypKZQjs0rVbt9Ut_Ke2u1oGENIlzy6NdvoyQzvZE_h5XrHL1Rbm78cfHvWz-tO4YtO4JwygOZvMLIwbJgmrynyS78dnUIjuldy2acrun0svNUV6r0YOc/w640-h310/Small+Multi+Prep+2.PNG" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><span style="font-family: arial;"><div><span style="font-family: arial;"><br /></span></div>But scaffolding exploded the data set to 28,000 records - at the same time it did solve the users problem</span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKAGGbkUmTD2ftW_151ch5m3M7KXBBGzO6zx5nbR6HU1fstdLYef1UjlDBIOlGa-FQ7T9cWgmu9nEsuc32tAre0OQHL1NZ9butOdcNfz_kihSLS0NgKpzBRHGSyrXPmnMPc9xzweKghuk/s1920/small+multi+final+images.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKAGGbkUmTD2ftW_151ch5m3M7KXBBGzO6zx5nbR6HU1fstdLYef1UjlDBIOlGa-FQ7T9cWgmu9nEsuc32tAre0OQHL1NZ9butOdcNfz_kihSLS0NgKpzBRHGSyrXPmnMPc9xzweKghuk/w640-h360/small+multi+final+images.png" width="640" /></a></div><br /></span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">Sometimes it is necessary to think beyond calculations and functions to create the viz you want to present and then it is often that the data need to be re-structured. When the data contains voids or is missing records, scaffolding is an option to make the data set solid.</span></div><div><br /></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">Hope this helps you better understand when and how to use different forms of scaffolding. The workbook used here can be downloaded at <a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/ScaffoldUseCasesUpload/Titleslide" target="_blank">Link to Examples</a></span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">Enjoy</span></div><div><span style="font-family: arial;">Jim</span></div></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">also see the video presentation on VizConnect at <a href="https://lnkd.in/dQh3Ewh" target="_blank">Video at</a></span></div>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-71432107766540648872020-12-10T13:04:00.003-06:002022-01-24T08:52:46.604-06:00My Top 5 Building Blocks on the Journey from Spreadsheets to Tableau<p> </p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p><p><br /></p><p>Presented at TFF 2020 see <a href="https://www.youtube.com/watch?v=c5I9kvrAwKc&list=PLlwjCfjqIxWlEZskASdjsN61DLOfmCk-Y&index=7" target="_blank">Video Here</a></p><p><span style="font-family: arial;">Like many of you, I am not a data scientist. Actually, my background is in engineering and marketing. I started Tableau with a lot of experience with Excel mixed with a bit of Access and I struggled for a while - that may sound familiar. </span></p><p><span style="font-family: arial;">Additionally, spreadsheet calculators and Tableau are fundamentally different. Spreadsheets work on a cell basis - values or formulas are in cells - cells can be copied or referenced in formulas to return another single cell value. Tableau works with dimensions that categorize data and measures that are actual values. Referring to dimension returns all the associated values in the data base - an entire column of values in a spreadsheet - </span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcUPjtXUC6TRY1DQpzDlQIQcTx_gLzpzfyIA0wDlaUD-WP3fhT7AgnykND-J6FVfcsx9TTMH2YfGEpMZUvbeFcEwkingKQF0DaI4ebj0pCUaUuN6koIL5deLdywdbJNFobt8DxtIqS84g/s1394/must+know+header.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="783" data-original-width="1394" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcUPjtXUC6TRY1DQpzDlQIQcTx_gLzpzfyIA0wDlaUD-WP3fhT7AgnykND-J6FVfcsx9TTMH2YfGEpMZUvbeFcEwkingKQF0DaI4ebj0pCUaUuN6koIL5deLdywdbJNFobt8DxtIqS84g/w400-h225/must+know+header.PNG" width="400" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">Ok, so what -</span><span style="font-family: arial;"> it meant learning Tableau from the ground up and along the way there were </span><span style="font-family: arial;">5 fundamental building blocks that once learned could be combined to create even the most complex solutions. Below I will present the skills needed and a couple of examples. Try them out with your own simple data sets. You can't break anything and you will learn a lot in the process.</span></p><p><span style="font-family: arial;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj21k0kymCGoopVytfX_9IAqD21fjJyBvtdV60iRTNNwrMq3DuiXIrJlyer04ROnA_i8gEo_bBFcv9jR1SMqVWFfeVjFXh6UXda6l06iTJdYvtcfy48P6bsSXJFc3I7b4QdHiUxHckRf9o/s1385/new+ds+header.png" style="font-weight: bold; margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="778" data-original-width="1385" height="113" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj21k0kymCGoopVytfX_9IAqD21fjJyBvtdV60iRTNNwrMq3DuiXIrJlyer04ROnA_i8gEo_bBFcv9jR1SMqVWFfeVjFXh6UXda6l06iTJdYvtcfy48P6bsSXJFc3I7b4QdHiUxHckRf9o/w200-h113/new+ds+header.png" width="200" /></a><b><br /><br /></b></span></p><p><span style="font-family: arial;">I grew up with a calendar on the refrigerator door - 7 columns for days and 4 to 5 rows for weeks and got comfortable seeing data organized in short wide tables. Spreadsheets have a similar structure so learning that Tableau needs a tall narrow data table structure is out of our comfort zone. For example, spreadsheet column headers like dates need to be in a single dimension (column) with each value a different date</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAOI70aPLy6m2otLOtBMfLi-L1XZdvws98aq941Va8yr3bUgql7sqv-o8WqjK5XWlF25wdV2yiBB03XcvhHUPyT69K2GlE8suen_6PAmOJOqt6EjfNuyDCx2OOJRTKYeusH7nS4kuU7Pc/s1286/wide+to+narrow.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="717" data-original-width="1286" height="279" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAOI70aPLy6m2otLOtBMfLi-L1XZdvws98aq941Va8yr3bUgql7sqv-o8WqjK5XWlF25wdV2yiBB03XcvhHUPyT69K2GlE8suen_6PAmOJOqt6EjfNuyDCx2OOJRTKYeusH7nS4kuU7Pc/w500-h279/wide+to+narrow.PNG" width="500" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">The way that is done is to pivot the data on Data Source tab</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDOB6lTp2sNh-PxYW8-DIFbhoeVaC0PJXUEHvtF5Rh9EIpNJbAiGTFkLUvMfTYDYeL1QRL5IZAdcA3joKnw60k1bzJ97DqRDKLIbzP71H7kshsehtxH-5xIX1qr418O3jcQ6T30F2LDz8/s1920/Pivot+columns.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDOB6lTp2sNh-PxYW8-DIFbhoeVaC0PJXUEHvtF5Rh9EIpNJbAiGTFkLUvMfTYDYeL1QRL5IZAdcA3joKnw60k1bzJ97DqRDKLIbzP71H7kshsehtxH-5xIX1qr418O3jcQ6T30F2LDz8/w500-h281/Pivot+columns.png" width="500" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">resulting in the tall narrow data structure needed </span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrVPLngeQK5HQlhZhic-eiwPVPDlTJj-KCkAzZEf7RO7Y9Y3zlAGXFUv6ISMg7onzXIY5CLu9mA8eFcIa03uQhWwzghBjAFzAt7UQlkoRxeL5FDnED3A6UBa4TFTHu3itcJGHpQDxQ-PQ/s299/Narrow+Format.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="299" data-original-width="286" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrVPLngeQK5HQlhZhic-eiwPVPDlTJj-KCkAzZEf7RO7Y9Y3zlAGXFUv6ISMg7onzXIY5CLu9mA8eFcIa03uQhWwzghBjAFzAt7UQlkoRxeL5FDnED3A6UBa4TFTHu3itcJGHpQDxQ-PQ/s0/Narrow+Format.PNG" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><span style="font-family: arial;">Next you need to understand how to combine data sets - using Joins to add a column or Unions to extend the length of the data </span><p></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVwmLeR_KYPP7i0vEtWsX36DBCTQINLd294C9pLvx_bTAUIpzquQ6jMvEdjooW2Rh-Vq_DdlcaWq5UXohTRxilWVOLm8GzRQ_DAy39-2UYiq2QdSaos-w4eiEbkPWZ7tF8P0AVknVgQSw/s1190/join+union+header.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="677" data-original-width="1190" height="285" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVwmLeR_KYPP7i0vEtWsX36DBCTQINLd294C9pLvx_bTAUIpzquQ6jMvEdjooW2Rh-Vq_DdlcaWq5UXohTRxilWVOLm8GzRQ_DAy39-2UYiq2QdSaos-w4eiEbkPWZ7tF8P0AVknVgQSw/w500-h285/join+union+header.PNG" width="500" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">When you need to add another "column" of data to the table use a Join . In Excel you would use a vlookup </span></p><p><span style="font-family: arial;">To add Quantity data to the Sales data above with data that looks like this:</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTZeBO_KYV4hsviSFs4pcKobtxbp5ufZxA7Ub6Q6NP_oXhVnYv8AyDmq32YuYd_oMrT7FeWn0q0SfxhkpKrtdUYkuOKjcfLKdimLlwGPfi74Jctr32pbpOVSL9Y6CXbm54xbG8crJTREc/s1920/quantity+data+to+join.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTZeBO_KYV4hsviSFs4pcKobtxbp5ufZxA7Ub6Q6NP_oXhVnYv8AyDmq32YuYd_oMrT7FeWn0q0SfxhkpKrtdUYkuOKjcfLKdimLlwGPfi74Jctr32pbpOVSL9Y6CXbm54xbG8crJTREc/s320/quantity+data+to+join.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;"><span style="font-family: arial;">The Quantity data need to match Sales by Date and by the Customer - so there are 2 join clauses </span></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFviAB83hbgJmPCHWitKvfox9OXYxl14hhgV_AAHC_MrhYn954YzKeJkCZosd5ReW8IC4WkcF7Xj59nxmIXZ1UMuUllj8f8xfraKsbHnKYo-AmPW_stwfpft51hJBl0hcLRu1JML3wyzs/s1920/Join+clause.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFviAB83hbgJmPCHWitKvfox9OXYxl14hhgV_AAHC_MrhYn954YzKeJkCZosd5ReW8IC4WkcF7Xj59nxmIXZ1UMuUllj8f8xfraKsbHnKYo-AmPW_stwfpft51hJBl0hcLRu1JML3wyzs/w500-h281/Join+clause.png" width="500" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">Alternatively, data that is updated regularly, like monthly Sales, using a Union of the new month to the existing data will append the new data to bottom of the existing</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg59S7g-lEiUgrE3yzoR8JwfvLIA1TZqP9xb3p42tmOXQEjwrB9j0zY_U4hBfj9cUXtkOJ83b9ZZhdoYLqcnVFgBAoSN_h44nglHONe7lm8Ob0SfL5RN_jBgfCJCJIFvTExCixNqPJhAmE/s1920/union+data+sets.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg59S7g-lEiUgrE3yzoR8JwfvLIA1TZqP9xb3p42tmOXQEjwrB9j0zY_U4hBfj9cUXtkOJ83b9ZZhdoYLqcnVFgBAoSN_h44nglHONe7lm8Ob0SfL5RN_jBgfCJCJIFvTExCixNqPJhAmE/w500-h281/union+data+sets.png" width="500" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">There is one more way to combine data that are at different level of aggregation or come from different data sources - that is Blending - </span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmY157XZouqZ7BQZ__b8kpyGsMvvvLA3X0pu3wRgculwE8_hzi7N4uuvREAE1gY8xMHq8xfHBn8PYtTeA3XtIP6MoSTYMseuUZ2fNjj9AcpU0tmB9RWVOqoXpIuGp9giiQEflJuGopw28/s1189/blend+header.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="664" data-original-width="1189" height="280" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmY157XZouqZ7BQZ__b8kpyGsMvvvLA3X0pu3wRgculwE8_hzi7N4uuvREAE1gY8xMHq8xfHBn8PYtTeA3XtIP6MoSTYMseuUZ2fNjj9AcpU0tmB9RWVOqoXpIuGp9giiQEflJuGopw28/w500-h280/blend+header.PNG" width="500" /></a></div><p><span style="font-family: arial;">Load your first data source into Tableau then add a second source</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPuRpCBfg9ipsmYmWKrBdOxhc6e8VAo4nEj7Y2yPTV0UbF4WcMphgpuyfgxq1xPwXXdce6A27csWx2-Ukz0kP8vRThdmWZACTw0fc6e6Ywd0Fi-mgO_-lAy9Sb1QEeK5oe4jMEAjUUrwk/s1920/correct+add+blend.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="351" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPuRpCBfg9ipsmYmWKrBdOxhc6e8VAo4nEj7Y2yPTV0UbF4WcMphgpuyfgxq1xPwXXdce6A27csWx2-Ukz0kP8vRThdmWZACTw0fc6e6Ywd0Fi-mgO_-lAy9Sb1QEeK5oe4jMEAjUUrwk/w625-h351/correct+add+blend.png" width="625" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">Those are basic examples of 3 ways to connect data - it can be more complex but with practice you will become comfortable selecting which to use - in later examples you will see how they affect your calculations</span></p><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh60IE1FQRRWofOBI-dOcYFE7FJKOVX6iEhIfrsr0MlI-2tqMsAjbUURGqy6LgLvod_ntLztWbNn91wBDXK4P-Psnc1SI5_EW1uOqaGF6-MvkMqn1MsaZ8Uw0zo7NBFtbHUy1KnGkDIF30/s1404/new+ooo+header.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="789" data-original-width="1404" height="113" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh60IE1FQRRWofOBI-dOcYFE7FJKOVX6iEhIfrsr0MlI-2tqMsAjbUURGqy6LgLvod_ntLztWbNn91wBDXK4P-Psnc1SI5_EW1uOqaGF6-MvkMqn1MsaZ8Uw0zo7NBFtbHUy1KnGkDIF30/w200-h113/new+ooo+header.png" width="200" /></a></div><p><br /></p><p><span style="font-family: arial;"> The order of operation is the sequence Tableau follows as it creates a viz.</span></p><p><span style="font-family: arial;">For each worksheet, Tableau will use a subset of the total data set to create a table that "underlies" the viz. You can think of it like a spreadsheet - its not really - it is the tall narrow format. Once the dimensional table is built - values are added and manipulated to create the final chart, graph or visual</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRXloEnEpXQaDysGcBszOhBwcjZroO7R48i-JocVGMxNried-_tnY8b7CuB-FGqEwpzrUz-yXTGc5F0nPlwc4BOqcPuZE13cw0gcgCl-7z7wBiabWXoTYsmCIWkJvpFe8n0E7cuxgBJvE/s1268/ooo+goal.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="718" data-original-width="1268" height="354" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRXloEnEpXQaDysGcBszOhBwcjZroO7R48i-JocVGMxNried-_tnY8b7CuB-FGqEwpzrUz-yXTGc5F0nPlwc4BOqcPuZE13cw0gcgCl-7z7wBiabWXoTYsmCIWkJvpFe8n0E7cuxgBJvE/w625-h354/ooo+goal.PNG" width="625" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><span style="font-family: arial;">While there are 10 steps in the order of operation, I find it useful to think of them in 3 groups</span><p></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4FbLGxPmoWAv93FBdxVuJABNxHSYycJQIktLnfW3KzuA5S1tn6in3jNkjV3_ux-iql7R0ssAiYipMuEZCWvsDcMERsQ74D_aR0pRyvWLdhzEHSEiJIJh_wsjfjLxLQdik5F5UzAhB9KM/s1048/orange+chevron.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="669" data-original-width="1048" height="399" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4FbLGxPmoWAv93FBdxVuJABNxHSYycJQIktLnfW3KzuA5S1tn6in3jNkjV3_ux-iql7R0ssAiYipMuEZCWvsDcMERsQ74D_aR0pRyvWLdhzEHSEiJIJh_wsjfjLxLQdik5F5UzAhB9KM/w625-h399/orange+chevron.PNG" width="625" /></a></div><br /><span style="font-family: arial;">The first 2 steps are workbook level and filter the data from the data source - they can be used to improve the performance of the book. </span><div><span style="font-family: arial;"><br /></span><div><span style="font-family: arial;">As dimensions are added to the Rows and Columns shelves and filter applied (Steps 3-5) the dimensional table for the worksheet is formed </span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">The final 5 steps load and manipulate the values in the sheet.</span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">A step by step explanation is too exhaustive for this post but is covered in </span><a href="https://jimdehner2.blogspot.com/2020/03/faq-series-order-of-operations.html" style="font-family: arial;" target="_blank">Orderofoperation</a><span style="font-family: arial;"> on this blog. </span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">When I first started, I printed (yes on paper) a copy of the order of operation as a reference. Next to syntax mistakes, using steps out of order is the most frequent cause of errors.</span><p></p><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPzrQlw-Xa23wZovGEUtUC4syZQbo1zTgBZWwqzeiym-VvPyEu6fyFJpwGOY_ukpcUpZyWGPyp0gCHYnXnSj7j8x9-bF1FPAAJwhuLAUqXYhZ4AV1PjpA0wLU5bRmXDN1QVvaZlSkucL4/s1371/New+syntax+header.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="784" data-original-width="1371" height="114" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPzrQlw-Xa23wZovGEUtUC4syZQbo1zTgBZWwqzeiym-VvPyEu6fyFJpwGOY_ukpcUpZyWGPyp0gCHYnXnSj7j8x9-bF1FPAAJwhuLAUqXYhZ4AV1PjpA0wLU5bRmXDN1QVvaZlSkucL4/w200-h114/New+syntax+header.PNG" width="200" /></a></div><p><br /></p><p><span style="font-family: arial;">While some of the formulas are similar to those in Excel, Tableau syntax is unique and needs to be learned. Fortunately, there is a Calculation Wizard to help</span></p><p><span style="font-family: arial;">If you have written a lot of Excel formulas the wizard user interface (U/I) will look familiar. Formulas are listed and grouped in categories. A drop down can filter the formula list making specific functions easier to find. </span><span style="font-family: arial;">On the right is an explanation of the formula you are working on and the arguments needed</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDVfl-OydFyBHE7vdKouy_iEo6vx5ENA9KoQLgnbQvnsbCT8-V56UziajCEa9q5AhIJnw2ngTYyAHEWbddFgJgNx9E87I8kkKz-jOh_GcvBwpT753KmYMEeGmFM3lVVe5sp_Sm4elwiZ8/s1279/calculation+wizard+2.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="722" data-original-width="1279" height="354" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDVfl-OydFyBHE7vdKouy_iEo6vx5ENA9KoQLgnbQvnsbCT8-V56UziajCEa9q5AhIJnw2ngTYyAHEWbddFgJgNx9E87I8kkKz-jOh_GcvBwpT753KmYMEeGmFM3lVVe5sp_Sm4elwiZ8/w625-h354/calculation+wizard+2.PNG" width="625" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><span style="font-family: arial;">Autofill and auto suggest are also included - at the bottom of the frame is the a Syntax is checked as you enter the formula.</span><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghwWmgnqSqdqmqCJAgD8d5jgJKYjHG6sWb_QoK40hDBzsaOj_GMSzMUgVuddShIze6Kme8H-D1iQjuAWCRbRypbExRUAbExw0t7yKU9VYDnrilNf2FMtXNyBECNDCvxgB54KWhSJgP2D0/s1920/error+messages.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="351" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghwWmgnqSqdqmqCJAgD8d5jgJKYjHG6sWb_QoK40hDBzsaOj_GMSzMUgVuddShIze6Kme8H-D1iQjuAWCRbRypbExRUAbExw0t7yKU9VYDnrilNf2FMtXNyBECNDCvxgB54KWhSJgP2D0/w625-h351/error+messages.png" width="625" /></a></div><br /><span style="font-family: arial;">The syntax checker will tell you when the formula is valid - that does not mean the logic returns the answer you expected . </span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">The most common types of errors are due to aggregation / non aggregation, trying to aggregate something that is already aggregated, mis-matched parentheses, or missing an operator -I still make them everyday - after a while you know how to correct them - see <a href="https://jimdehner2.blogspot.com/2020/01/faq-series-cannot-mix-aggregate-and-non.html" target="_blank">aggregation</a> to learn more about aggregation errors</span><p></p><p><span style="font-family: arial;">You didn't learn Excel formulas overnight and the same is true for Tableau - you will find there are a few you use repeatedly that will be like second nature and others that you need to look up. </span></p><p><span style="font-family: arial;"><b></b></span></p><div class="separator" style="clear: both;"><span style="font-family: arial;"><b><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwFT4ltn38rjV4AA1G7uCNFHsDWpd1Xvk-BefTN5nc3rD-mxNgtVC2IhCrGNo_gMRxjYmJtj2iPpDDtu-oAljVxcPVbpy7Hw6q54TpbyA-Ehk2fFjcqB_JWXsK0dLpyv2Et3HnLcpNDUI/s1392/new+calculation+header.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="782" data-original-width="1392" height="113" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwFT4ltn38rjV4AA1G7uCNFHsDWpd1Xvk-BefTN5nc3rD-mxNgtVC2IhCrGNo_gMRxjYmJtj2iPpDDtu-oAljVxcPVbpy7Hw6q54TpbyA-Ehk2fFjcqB_JWXsK0dLpyv2Et3HnLcpNDUI/w200-h113/new+calculation+header.PNG" width="200" /></a></b></span></div><span style="font-family: arial;"><b> </b></span><p></p><p><span style="font-family: arial;">Calculations are the backbone of creating more advanced analyses and the visuals that go alone with them. </span></p><p><span style="font-family: arial;">There are 4 basic types of calculations in Tableau</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxlfk7eHZF5rRMZdidT9VQ8ZyfQpKhRp-QoPfY2t4MRusTA9y-g7OCAur9hiXLSTixjGYhM8xh5s2Ze_Wojg_uZoh1v3X3pYzBKpzjydGjDWdtfblPDiXOzb4W8bYkG8dTpVbULNJE9h8/s1397/4+calc+syntax.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="788" data-original-width="1397" height="354" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxlfk7eHZF5rRMZdidT9VQ8ZyfQpKhRp-QoPfY2t4MRusTA9y-g7OCAur9hiXLSTixjGYhM8xh5s2Ze_Wojg_uZoh1v3X3pYzBKpzjydGjDWdtfblPDiXOzb4W8bYkG8dTpVbULNJE9h8/w625-h354/4+calc+syntax.PNG" width="625" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><p></p><p><span style="font-family: arial;"><b>Simple calculations</b>, including "If ... Then " conditional statements look similar to those in excel except they are typically written at an aggregated level - Think back to the data structure, Dimensions and Measures refer to and entire "column" of Excel data - </span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">so to find the average selling price at the level of dimensions in the viz -</span></p><p></p><div style="text-align: center;"><span style="font-family: arial;">ASP=Sum(sale)/Sum(quantity) </span></div><div style="text-align: center;"><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">Will return this when Category is on the Rows</span></div><div><span style="font-family: arial;"><br /></span></div><p></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p></p><div style="text-align: center;"><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9GGJBeZzLfyZwohKcpFy5zHaCIEDIUCsGc5lYeYRXG9zMSNXFTbBrHL4DP5rkTMZBw4Mn8YHdwJ5Sil1_ieRHanTJV8vstD_2ZjeOVktZf6dwTZtM8MYqG13cbE2Qst2AqMj-l8l1-nA/s573/asp+at+cat+level.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="424" data-original-width="573" height="463" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9GGJBeZzLfyZwohKcpFy5zHaCIEDIUCsGc5lYeYRXG9zMSNXFTbBrHL4DP5rkTMZBw4Mn8YHdwJ5Sil1_ieRHanTJV8vstD_2ZjeOVktZf6dwTZtM8MYqG13cbE2Qst2AqMj-l8l1-nA/w625-h463/asp+at+cat+level.PNG" width="625" /></a></div><br /><div class="separator" style="clear: both; text-align: left;"><span style="font-family: arial;">and this</span></div></div><p></p></blockquote><p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGzCwewhyphenhyphenJW36aEqUMLqxWOfrXkTcEOu5beR1JXvvJvbSoNAkbygfDNg3I9B8KABu_BB0glMJhEpkFV8kzUOJcIZlJHs2ktqO6wrVb6SOVTXD8sw2SFAbSjG9rCuqVm8rwWOJOzOROfMU/s670/asp+at+the+subcat+level.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="670" height="499" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGzCwewhyphenhyphenJW36aEqUMLqxWOfrXkTcEOu5beR1JXvvJvbSoNAkbygfDNg3I9B8KABu_BB0glMJhEpkFV8kzUOJcIZlJHs2ktqO6wrVb6SOVTXD8sw2SFAbSjG9rCuqVm8rwWOJOzOROfMU/w625-h499/asp+at+the+subcat+level.PNG" width="625" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;"><span style="font-family: arial;">Conditional statements are coded as If ... Then ... Elseif ... End </span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"> </span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">This statement would create Sales Groups out of Regions</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><b><div class="separator" style="clear: both; text-align: center;">If [Region]="East" or [Region]= "West" then "Costal"</div><div class="separator" style="clear: both; text-align: center;">Elseif [Region] = "Central" then "Middle" </div><div class="separator" style="clear: both; text-align: center;">else "South" end</div></b></span></div><div><br /></div><span style="font-family: arial;">and return this</span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR9goeW9K643eHxAsT4IiYJFRgXflbNCf5ttI7QLicHSQGXR0vOmWMt19HMUDu_cDEYtw9WNrPm1t4QOnDLEjUrcYLcBvgGFY7na449mKjbypC44QzHpruMlj5g1HoljGd2p5gy_B6POE/s766/if+then+example.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="412" data-original-width="766" height="336" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR9goeW9K643eHxAsT4IiYJFRgXflbNCf5ttI7QLicHSQGXR0vOmWMt19HMUDu_cDEYtw9WNrPm1t4QOnDLEjUrcYLcBvgGFY7na449mKjbypC44QzHpruMlj5g1HoljGd2p5gy_B6POE/w625-h336/if+then+example.PNG" width="625" /></a></div><br /><span style="font-family: arial;">Conditional statements can be nested or used in any other type of calculation<br /></span><p><span style="font-family: arial;">The more you write them the more comfortable you will become with them</span></p><p><span style="font-family: arial;"><b>Dates functions</b> - real dates - are special type of data in the Tableau - they self sequence, sort and most of all can be used in date calculations. The functions can be discrete or continuous and are based on truncating the full data time series at different levels</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqtGWq3e4-CduMw-ocxNi3Jw-Vp7fhidwlTIJytZ77jFK0hmGbyzR5F0xL5X1nWBpyzEgZPFfAg_ToSYGfsxHsQPGPZIumVz9wJz_XhoNlN2sPcxSD3OKyMlTjnl6ON4jS3X5tDPeD6pM/s1861/grey+chevrons.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="363" data-original-width="1861" height="123" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqtGWq3e4-CduMw-ocxNi3Jw-Vp7fhidwlTIJytZ77jFK0hmGbyzR5F0xL5X1nWBpyzEgZPFfAg_ToSYGfsxHsQPGPZIumVz9wJz_XhoNlN2sPcxSD3OKyMlTjnl6ON4jS3X5tDPeD6pM/w625-h123/grey+chevrons.PNG" width="625" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">Some of the date functions - year, month, quarter, day seem familiar - others like datetrunc, dateadd, datediff will take some getting used to see <a href="https://jimdehner2.blogspot.com/2020/02/dates-functions-and-other-necessary.html" target="_blank">date functions</a> for more</span></p><p><span style="font-family: arial;">Like Excel, date functions come in 2 different types</span></p><p></p><ul><li><span style="font-family: arial;">Those that return dates - Datetrunc in Tableau or Date Value in Excel</span></li></ul><ul><li><span style="font-family: arial;">and those that return a reference to the date like Month in both systems</span></li></ul><span style="font-family: arial;">Date functions can be used with time also. They are very flexible but do take some practice. I have several post on converting strings to dates, calculating durations, and excluding weekend to use "Business Days" - see <a href="https://jimdehner2.blogspot.com/search/label/Dates" target="_blank">Date Examples</a></span></div><div><span style="font-family: arial;"><br /></span><div><span style="font-family: arial;"><b>LOD Expressions -</b> Extremely powerful, LOD's allow you to create additional layers in your data are level above that entered when you loaded the data</span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP7hEWch0sAmgU92JWiLWKPssZQZZWBPtdF16U9bYxVqq1HPhg-IZZxprXWI3ZxWJMmRY46gkn4y1sm1cDL6zaxAv8NBRg2pfFUsozoCLmxW_dJDYtVS-Bdk56fXbiaOYgaSjJwPWwWrg/s1187/lod+pyramid.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="672" data-original-width="1187" height="283" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP7hEWch0sAmgU92JWiLWKPssZQZZWBPtdF16U9bYxVqq1HPhg-IZZxprXWI3ZxWJMmRY46gkn4y1sm1cDL6zaxAv8NBRg2pfFUsozoCLmxW_dJDYtVS-Bdk56fXbiaOYgaSjJwPWwWrg/w500-h283/lod+pyramid.PNG" width="500" /></a></div><br /></div><div><span style="font-family: arial;">While LODs aggregate a measure, they are not aggregates in themselves and can be used in simple calculations, nested in other LOD's, and included in Table Calculation</span></div><div><span style="font-family: arial;"><br /></span></div><div style="text-align: center;"><span style="font-family: arial;"><b>{Fixed Segment, Region : Sum(Sales)}</b></span></div><p></p><p><span style="font-family: arial;">In words says take all the combinations of Segment (4) and Region (4) and total the Sales anew save them for use them later - and you have established a lay in the data set that includes 16 values. </span></p><p><span style="font-family: arial;"><b>Table Calculations</b> With a background in Excel, table calculations will seem familiar. Like Excel formulas, they operate on the rows and columns of the data table that underlies the worksheet but that is where the similarity ends.</span></p><p><span style="font-family: arial;">In Tableau there are 2 concept - Scope and Direction that govern how the calculation is applied to the data in the table </span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd49yL6F_paP4cLfP30BwJFAELwSZKvEIqJkV1KjsH1LjyYWhigDvVOJ2ApZI9c9BrqA-IQIPVPipcXYd8wTj0P51pRrc2rhoW9eVS4zsM4Fkcq0j-jx32Fw5XRhTSaU9JkNMfvH4sFzk/s1279/scope+and+direction+2.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="717" data-original-width="1279" height="350" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd49yL6F_paP4cLfP30BwJFAELwSZKvEIqJkV1KjsH1LjyYWhigDvVOJ2ApZI9c9BrqA-IQIPVPipcXYd8wTj0P51pRrc2rhoW9eVS4zsM4Fkcq0j-jx32Fw5XRhTSaU9JkNMfvH4sFzk/w625-h350/scope+and+direction+2.PNG" width="625" /></a></div><br /><span style="font-family: arial;">Table calculations come in 3 types</span><p></p><p></p><ul><ul><li><span style="font-family: arial;">Those that aggregate or rank values in the table like </span></li><ul><li><span style="font-family: arial;">Window_Avg, Running_Sum, Rank_Unique</span></li></ul></ul></ul><ul><ul><li><span style="font-family: arial;">Others used to navigate the table like:</span></li><ul><li><span style="font-family: arial;">Lookup, Previous_Value, First, Last</span></li></ul></ul></ul><ul><ul><li><span style="font-family: arial;">Act as the interface to R or Python</span></li><ul><li><span style="font-family: arial;">Script_Real, Script_Int</span></li></ul></ul></ul><p></p><p><span style="font-family: arial;">You can use the Quick Table Calculator </span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDXxNEM3S75Wthv9E4dFpB9CFcb6f0didxGiDM-dLo5QQziMi6Af67l5jT__WbEdKKTdihMecETQCbeZPt83aNIhbZqFEE3xpaV-2xhwxA7an7eTFHnILyJZz6XhxBN4UI0y36Md0EpCA/s1920/table+quick+calc.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="351" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDXxNEM3S75Wthv9E4dFpB9CFcb6f0didxGiDM-dLo5QQziMi6Af67l5jT__WbEdKKTdihMecETQCbeZPt83aNIhbZqFEE3xpaV-2xhwxA7an7eTFHnILyJZz6XhxBN4UI0y36Md0EpCA/w625-h351/table+quick+calc.png" width="625" /></a></span></div><p><span style="font-family: arial;"><br /></span></p><span style="font-family: arial;">Or you can write your own using the Calculation Wizard</span><p></p><p><span style="font-family: arial;">The Direction for the calculation will default to Across but can be changed directly using "Compute Using" or opening the Editor </span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhz3b9NHQwlSGFji-ESFolB_i7z8un7RFdfM0QvwNWcQQcXv2KIfTKaEvjoDzzJ3fqBP0zCZ9OeQCjzdqEEBOkEYa8UX8mKI4WM63xKU58MiBSrBsttCy3QOlWtbj9CfHFarIc-FtuqmhU/s1920/direction+selection.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="351" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhz3b9NHQwlSGFji-ESFolB_i7z8un7RFdfM0QvwNWcQQcXv2KIfTKaEvjoDzzJ3fqBP0zCZ9OeQCjzdqEEBOkEYa8UX8mKI4WM63xKU58MiBSrBsttCy3QOlWtbj9CfHFarIc-FtuqmhU/w625-h351/direction+selection.png" width="625" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2xU4Ydfqs07DtpuQxYQqBx0rgo2-a2p2HDCeNe5fiCQbvsqGIWllNs3hN29Y9-bdAlSaUg7B5kY0bC7txxsmRB7UYJr8d6ek2DPEgmO9IPbDojy7Z-ce8w_26xRkpQnXphEscy_QVhTo/s1388/New+tool+kit+header.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="780" data-original-width="1388" height="113" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2xU4Ydfqs07DtpuQxYQqBx0rgo2-a2p2HDCeNe5fiCQbvsqGIWllNs3hN29Y9-bdAlSaUg7B5kY0bC7txxsmRB7UYJr8d6ek2DPEgmO9IPbDojy7Z-ce8w_26xRkpQnXphEscy_QVhTo/w200-h113/New+tool+kit+header.PNG" width="200" /></a></div><p><br /></p><p><span style="font-family: arial;"><b>Filters,</b> sets and parameters give you and the user ways to select, limit and group data. Just like in Excel, filters limit the data in the underlying table, Data that is filtered out is no longer available for calculations or presentation on the worksheet. Filters can be applied to the workbook level, to dimensions or to measure values after they are added to the table</span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvAxRMl0UY2csbGZLqa6TCSAW9y9oquS_ZXR3f89xAGw-6IzeKJ6hGVQTCg8cUttf-svi1CXKiIsrI03AS9ssiENvb7n4Cj3KaYE1YGLKL_zWuu-ntIRyVXdZ0-krfeK5KkKid5OFaVzA/s1920/dimension+filters.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="351" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvAxRMl0UY2csbGZLqa6TCSAW9y9oquS_ZXR3f89xAGw-6IzeKJ6hGVQTCg8cUttf-svi1CXKiIsrI03AS9ssiENvb7n4Cj3KaYE1YGLKL_zWuu-ntIRyVXdZ0-krfeK5KkKid5OFaVzA/w625-h351/dimension+filters.png" width="625" /></a></div><br /><p><span style="font-family: arial;">Measure filters can be applied at the record before aggregation or the after selecting an aggregation level</span></p><p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiDFc-fS2XmWotjqNQ_6X5NkHrFSM3mRnKcPCpAVB0jNGCY6TLE5p9bvYU74KuPPV8s5hQ6qLBgvEKvZDHO7ya7NJEH-FWyEzkgJVtL7_O4laNsUQ0A6mnQi9SFQLXoio6cNZkYP_46nU/s1920/measure+filters.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="1080" data-original-width="1920" height="351" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiDFc-fS2XmWotjqNQ_6X5NkHrFSM3mRnKcPCpAVB0jNGCY6TLE5p9bvYU74KuPPV8s5hQ6qLBgvEKvZDHO7ya7NJEH-FWyEzkgJVtL7_O4laNsUQ0A6mnQi9SFQLXoio6cNZkYP_46nU/w625-h351/measure+filters.png" width="625" /></a></p><p><br /><span style="font-family: arial;"><b>Sets </b>classify dimensions into 2 groups - the "IN" group selected by the user and all other values are in the "OUT" group. All records are still available in the table allowing comparisons between the In and the Out groups. Sets can be selected manually or by a formula and multiple sets can be combined to identify items in both or only a single group. Set actions can be used to change set members by selecting from a value picker or dropdown. Finally sets are formed in Step 4 of the Order of Operation after Context filters have been applied but before Dimensional filters - giving the user several options when comparing values. </span></p><p><span style="font-family: arial;"><b>Parameters </b>allow the user to input a single static value by a selection from a list or direct entry into the workbook. The value is constant until manual changed and is the same throughout the entire workbook. </span></p><p><span style="font-family: arial;">But parameters don't do anything until they are included in a calculation (any type) or a filter. It is the formula or the filter that does affects the viz not the parameter. The parameter value is the same everywhere in the workbook but it can be used in different calculations or filters and need not be applied to every worksheet. </span><span style="font-family: arial;">Changing the parameter value will affect all the calculations or filters where the parameter is used. Parameter actions can be used to change the parameter value visual elements on the worksheet</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijzYiyXyiMAvxGC9tYhnw4Endi1XfXobsYNhpP48Nmi-QbV-9VYC6gnxNLN7TmfaNm9UVpyfnPoC5Kg_kpzCusfvzGEfDvadUVl57Dp-zbQN2kGfWoDWcS0MWkjS20SBTbfcgEnzwkrh4/s1285/parameter+basics.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="717" data-original-width="1285" height="350" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijzYiyXyiMAvxGC9tYhnw4Endi1XfXobsYNhpP48Nmi-QbV-9VYC6gnxNLN7TmfaNm9UVpyfnPoC5Kg_kpzCusfvzGEfDvadUVl57Dp-zbQN2kGfWoDWcS0MWkjS20SBTbfcgEnzwkrh4/w625-h350/parameter+basics.PNG" width="625" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">The parameter list can be updated dynamically when the workbook is opened - </span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0ewjjh8chAh0dzL9dsAT_UmasTC4rn2hImdIYtLDyNMIsxM5hAqc6fCPcO3KTsy6CrF5sVUsIc6SO2h22pdKniOAgLISJPQvsJp1g6vyrQXlg2P89iBLnY2r_Rws5QmB2nTcXikRvBbE/s1920/dynamic+param.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="351" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0ewjjh8chAh0dzL9dsAT_UmasTC4rn2hImdIYtLDyNMIsxM5hAqc6fCPcO3KTsy6CrF5sVUsIc6SO2h22pdKniOAgLISJPQvsJp1g6vyrQXlg2P89iBLnY2r_Rws5QmB2nTcXikRvBbE/w625-h351/dynamic+param.png" width="625" /></a></div><br /><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheiVaGCeE-J7WYcM00eoGsigCYDUF5CzZjsukNpKEtUEKGaOe9wlRqvZK_c2UwMH53UAXfXUgP_0G-0nn8SacLmwKiYnly7uDC91SpZd9Ubvrt96OvFZRtVZ6ewaSmF8dKl6vF5m13l0M/s1383/new+last+header.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="787" data-original-width="1383" height="114" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheiVaGCeE-J7WYcM00eoGsigCYDUF5CzZjsukNpKEtUEKGaOe9wlRqvZK_c2UwMH53UAXfXUgP_0G-0nn8SacLmwKiYnly7uDC91SpZd9Ubvrt96OvFZRtVZ6ewaSmF8dKl6vF5m13l0M/w200-h114/new+last+header.PNG" width="200" /></a></div><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">Those are the 5 building blocks on the road to understanding Tableau. Combined simple calculations were used to create the viz below. It uses a parameter action to select the date, set action to select states and segments, LOD's for YTD and YoY calculations </span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjgt4UZ7n7OLiBt0zJr9JlhwA29kAE4eEkOCDURnN91nQipFdMJZM2_5NxptsOh6zK67NsbORzYzHNiqAGMStuIfPArOuOVhNUaIh74uxFNGnEV67HLjg0nYEYbNtg4E-gg3p9FcbpJKQ/s1709/combined+example.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="906" data-original-width="1709" height="340" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjgt4UZ7n7OLiBt0zJr9JlhwA29kAE4eEkOCDURnN91nQipFdMJZM2_5NxptsOh6zK67NsbORzYzHNiqAGMStuIfPArOuOVhNUaIh74uxFNGnEV67HLjg0nYEYbNtg4E-gg3p9FcbpJKQ/w640-h340/combined+example.PNG" width="640" /></a></div><br /><p></p><p><span style="font-family: arial;">It may seem formidable but with a little work on each you will develop a deep understanding of how Tableau works.</span></p><p><span style="font-family: arial;">The workbooks that accompany these examples can be found at <a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/MyTop5/datastruc1" target="_blank">Tableau Public Link</a></span></p><p><br /></p><p><span style="font-family: arial;">Jim</span></p></div></div><div><span style="font-family: arial;"><br /></span></div>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-52391655656590436122020-11-18T15:24:00.011-06:002022-01-24T08:52:59.364-06:00FAQ Series - Net Promoter Score<blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p><span style="font-family: arial;"></span></p><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Recently I had someone ask about calculating the Net Promoter Score in Tableau. It's not difficult but first a word on what the NPS is and who uses it -</span></p><p><span style="font-family: arial;">The Net Promoter Score is often used by consumer products companies to measure customer loyalty. It is easy to administer - just collect consumer responses to "How likely are you to recommend our product/service to a friend or colleague? Responses are retrieved on a 0 to 10 scale. Response ratings of 9 or 10 are "Promoters", those rated 6 or less are "Detractors" and the 7 and 8 group are "Passives" - the NPS is the percent to total for Promoters minus that for Detractors based on the count or responses in each group and overall.</span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Pretty simple, repeatable, and has been show to produce consistent results. So how to use Tableau to calculate the results?</span></p><p><span style="font-family: arial;">Typical survey data might look like this </span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivJu_2RDTIFXVabebFFk87SozmlWLbCp9gRHGE18qI8dDXl33bzb86GWaaDSlyAvdO_UQXO34ZgttNAktxjM8OQ5aONlPMdMVTLHZbZU0x2xzw2eAYMF-KPauH6Rezej6uCIoX-9SSsHY/s450/typ+survey+data.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="450" data-original-width="362" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivJu_2RDTIFXVabebFFk87SozmlWLbCp9gRHGE18qI8dDXl33bzb86GWaaDSlyAvdO_UQXO34ZgttNAktxjM8OQ5aONlPMdMVTLHZbZU0x2xzw2eAYMF-KPauH6Rezej6uCIoX-9SSsHY/s320/typ+survey+data.PNG" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><p></p><p></p><div class="separator" style="clear: both; text-align: left;"><span style="font-family: arial;">A code to identify the responder, date (here just a year but you may have data on a monthly basis) and a response to the "Likely to Recommend) question - numeric value form 0-10</span></div><div class="separator" style="clear: both; text-align: left;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both; text-align: left;"><span style="font-family: arial;">Start by classifying each response as "Promoter", "Detractor" or "Passive"</span></div><div class="separator" style="clear: both; text-align: left;"><span style="font-family: arial;"><br /></span></div><p></p><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b>If [Likely to recommend]>=9 then "Promoter"</b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><b><div class="separator" style="clear: both; text-align: center;">elseif [Likely to recommend]<=6 then "Detractor"</div><div class="separator" style="clear: both; text-align: center;">else "Passive" end</div></b></span></div><p></p><div style="text-align: center;"><br /></div><p></p><p><span style="font-family: arial;">Then the Percent to Total can be done with an LOD</span></p><p style="text-align: center;"><span style="font-family: arial;"><br /></span></p><div style="text-align: center;"><span style="font-family: arial;"><b>sum({ FIXED [Year],[Promoter Classification]:countd([ID Code]) })/</b></span></div><div style="text-align: center;"><span style="font-family: arial;"><b>sum({ FIXED [Year]:countd([ID Code]) })</b></span></div><div style="text-align: center;"><br /></div><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">then the NPS is just the difference between the Promoter and Detractor percentage</span></p><p align="center" style="margin: 0in; text-align: center;"><br /></p><div style="text-align: left;"><span style="font-family: arial;"><div style="font-weight: bold; text-align: center;">{ FIXED [Year]:</div><div style="font-weight: bold; text-align: center;">(sum({ FIXED [Year],[Promoter Classification] : ( if Min([Promoter Classification]) = "Promoter" then [lod percent by class] end) })</div><div style="font-weight: bold; text-align: center;">-sum({ FIXED [Year],[Promoter Classification] : ( if Min([Promoter Classification]) = "Detractor" then [lod percent by class] end )}</div><div style="font-weight: bold; text-align: center;"><br /></div><div style="text-align: left;">and then the results look like this</div><div style="text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6dlL-9yYEL_4u3lx_t7i1BpPrNOVUm2__yVskB7RB74Px7Cf_V0TM2XIvc_TZAPxzH89YZ2RcGbJ6t8_TGF3sGrCE_4s42bzQ6ca8w7a-xZxbPnW5XAO32NsK6Tz0tkyCteNp7mfw6QQ/s818/nps+detail+final.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="387" data-original-width="818" height="189" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6dlL-9yYEL_4u3lx_t7i1BpPrNOVUm2__yVskB7RB74Px7Cf_V0TM2XIvc_TZAPxzH89YZ2RcGbJ6t8_TGF3sGrCE_4s42bzQ6ca8w7a-xZxbPnW5XAO32NsK6Tz0tkyCteNp7mfw6QQ/w400-h189/nps+detail+final.PNG" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div></span></div><div style="text-align: left;"><span style="font-family: arial;"><div class="separator" style="clear: both; text-align: left;">and the Net Promoter Score is the difference between the percentage of Promoters less the Detractors </div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJ-T0bMVLIgyeeU5VlRdj4g6DsRGFEA1vrhhUyrmX4Q_E1BSiuKj7uU2yExknx0W9ukb4RMgXZhBbt5ZVDBOittylV_6hlTkL7CpWDNrDd52orYk2smoLps0tvRHH2SieieeauJQebFVI/s549/the+resultant+NPS.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="359" data-original-width="549" height="262" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJ-T0bMVLIgyeeU5VlRdj4g6DsRGFEA1vrhhUyrmX4Q_E1BSiuKj7uU2yExknx0W9ukb4RMgXZhBbt5ZVDBOittylV_6hlTkL7CpWDNrDd52orYk2smoLps0tvRHH2SieieeauJQebFVI/w400-h262/the+resultant+NPS.PNG" width="400" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;">It no more difficult than that. </div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">To learn more about Net Promoter Scores see :<a href="https://www.qualtrics.com/experience-management/customer/net-promoter-score/">NPS Source</a></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">The workbook contain the calculations used here can be found at: <a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/NPSinTableauOnly/Dashboard1" target="_blank">Link to NPS workbook</a></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">Enjoy</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">Jim</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><br /></div><br /><div class="separator" style="clear: both; text-align: left;"><br /></div></span></div><div style="text-align: left;"><span style="font-family: arial;"><br /><div style="text-align: left;"><br /></div></span></div>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-88615104809498286182020-10-17T12:58:00.004-05:002022-01-24T08:53:16.571-06:00FAQ Series - Fiscal Years<p> </p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Many businesses use a fiscal calendar for accounting and reporting . Their fiscal year can start on the first day of any month and may not align with the start of a calendar quarter. Tableau makes it easy to adjust for the fiscal year start. </span></p><p><span style="font-family: arial;">Open the date field and set the Default Property - Fiscal Year Start to the proper Month</span></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEXLr9LAudRZTzj0VQRrF_ZaqtmPRaqCc3u1uWF8AFtG3pBVNxlE6vfMHE7OJTtW4Ri-MlLMLH9coXSo2iwe2Kthx7exRFzN8iCRMtAEHGPNsg01Rg7ft2E-Yoatj3On6qLfX1nJqcOzs/s1920/path+for+start+date.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEXLr9LAudRZTzj0VQRrF_ZaqtmPRaqCc3u1uWF8AFtG3pBVNxlE6vfMHE7OJTtW4Ri-MlLMLH9coXSo2iwe2Kthx7exRFzN8iCRMtAEHGPNsg01Rg7ft2E-Yoatj3On6qLfX1nJqcOzs/w640-h360/path+for+start+date.png" width="640" /></a></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><br /></span></div><p></p><p><span style="font-family: arial;"></span></p><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><span style="font-family: arial;">The fiscal year starts in the month selected (August in this example) and</span><span style="font-family: arial;"> ends 11 months later (July) in the subsequent calendar year </span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">Quarters are 3 month periods starting with the fiscal year start</span></div><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuHyR3lTnDvbpMj8uBFQnkmj2WNZyOHaGWKwED7HJMgz8Ian0ZXu0zDAuIUD5D6hHTR8ZgVJH5J3dIgFgN_u40xZAdgpJAj7MxDuLpumzGsR9JlgmqfZGXOV1Nw2prVremPfEX8M9woQQ/s1920/alignment+of+default+FY+FQ.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuHyR3lTnDvbpMj8uBFQnkmj2WNZyOHaGWKwED7HJMgz8Ian0ZXu0zDAuIUD5D6hHTR8ZgVJH5J3dIgFgN_u40xZAdgpJAj7MxDuLpumzGsR9JlgmqfZGXOV1Nw2prVremPfEX8M9woQQ/w640-h360/alignment+of+default+FY+FQ.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;"><span style="font-family: arial;">The date field can be used in any type of chart, can be filtered, or placed on tile cards to adjust to the proper fiscal year</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifGdNrvbQ_50toVb6Ag4nN88amQQnEZmBsbnBvYWF6ckK_9rvRmXOb0ZzQUe54g68B_pohnEUQa_6PymtoZCJ6_tAgKBv6G748zzB5qrw7GWV-0RcYFabZWjDviGkVDtT6v04dpVnGHf8/s1920/default+chart+example.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifGdNrvbQ_50toVb6Ag4nN88amQQnEZmBsbnBvYWF6ckK_9rvRmXOb0ZzQUe54g68B_pohnEUQa_6PymtoZCJ6_tAgKBv6G748zzB5qrw7GWV-0RcYFabZWjDviGkVDtT6v04dpVnGHf8/w640-h360/default+chart+example.png" width="640" /></a></div><br /><span style="font-family: arial;">But problems arise when doing any of calculation based on date functions </span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">In the LOD below the Year(Order Date) is the calendar year - not the anticipated fiscal year </span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b>{ FIXED Year([Order Date]):sum([Sales])}</b></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b><br /></b></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUOnKujRVDECO6sNcmdJKDo55NiPA1C9DSh3Br7yoGujY9RDZf7YudT0wfg-3w_J0Hh_ZOSiSp4eLn_KDaxyWhhw8xHecJeOw1ehHSX857DVwJFd3LiC5yEsAzrSoXOnPtNvGwt2Ia_kM/s1920/total+based+on+CY.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUOnKujRVDECO6sNcmdJKDo55NiPA1C9DSh3Br7yoGujY9RDZf7YudT0wfg-3w_J0Hh_ZOSiSp4eLn_KDaxyWhhw8xHecJeOw1ehHSX857DVwJFd3LiC5yEsAzrSoXOnPtNvGwt2Ia_kM/w640-h360/total+based+on+CY.png" width="640" /></a></div><br /><b><br /></b></span></div><span style="font-family: arial;">Date functions don't recognize fiscal years so a different approach is needed </span><div><span style="font-family: arial;"><br /></span></div><div><p><span style="font-family: arial;">This example came from a recent TCish BrainDate- The user has an August fiscal year start and wanted the to be able to select any calendar date and display the current and the prior YTD and QTD sales </span></p><p><span style="font-family: arial;">(Note: in the US retail sector February and August fiscal year starts are not uncommon - Inventory taxes are often evaluated on inventory levels at the end of January so retailers set the FY start in February or 6 months later - manufacturers who sell into the segment frequently want to be able to see reports or analyses in the retailer Fiscal Year)</span></p><p></p><p><span style="font-family: arial;">Conceptually, the approach is simply determining the fiscal year start date based on a parameter and the </span><span style="font-family: arial;">Current Date (a calendar date) set by another parameter - used as the end date for YTD and QTD analysis. </span></p><p><span style="font-family: arial;">Note: </span><span style="font-family: arial;">The formulas to determine the quarterly adjustment between the fiscal quarters and the calendar month were difficult and took some trial and error - for that reason I included them in the text so you could copy and paste them - the other calculations deciding which calendar dates are between the start and end dates of the fiscal period. </span></p><p><span style="font-family: arial;">Start by creating a parameter to select a start month - The values are 1-12 and the display is the Month to make it easy on the user</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyDCdCXTKjH7cW2FvJZ8cSy8Ry3Lioy9KhBnus6SRVQVyG5xNNMrGrbMs8g4eHizk1Xn0jcARM3W4qxf_TfoSYU6mJ99fp7Mj9GAPR0t3z9CZLcmO71tRDZFm9Z_O2OpvJNXJV9vKd9es/s560/start+month+param.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="560" data-original-width="556" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyDCdCXTKjH7cW2FvJZ8cSy8Ry3Lioy9KhBnus6SRVQVyG5xNNMrGrbMs8g4eHizk1Xn0jcARM3W4qxf_TfoSYU6mJ99fp7Mj9GAPR0t3z9CZLcmO71tRDZFm9Z_O2OpvJNXJV9vKd9es/w398-h400/start+month+param.PNG" width="398" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><span style="font-family: arial;">another parameter is simply a date parameter </span></div><div><span style="font-family: arial;"><br /></span><p></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoWaUjDG2_dq2Cb3LiBUGK22yHFCJS4D8kPXq74UKfuJHvSz8LgHIO4lc5-c_B3TXpQYSOKEnx-5aC7RvdW2Yk31QaVTlfYgY9jy7EcdxXnwoSbJo2JV0SB1EPjpsXwYfQdjJNLrIrXd0/s554/current+date+param.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="283" data-original-width="554" height="204" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoWaUjDG2_dq2Cb3LiBUGK22yHFCJS4D8kPXq74UKfuJHvSz8LgHIO4lc5-c_B3TXpQYSOKEnx-5aC7RvdW2Yk31QaVTlfYgY9jy7EcdxXnwoSbJo2JV0SB1EPjpsXwYfQdjJNLrIrXd0/w400-h204/current+date+param.PNG" width="400" /></a></div><p><br /></p><p><span style="font-family: arial;">The FY start date is just based on the Start date parameter converted to a real date</span></p><p><span style="font-family: arial;"></span></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p></p></blockquote><p style="text-align: center;"><b><span style="font-family: arial;"> Dateadd('year',0,[Convert Start date to Real date])</span></b></p><p><span style="font-family: arial;">But finding the month of the quarter start date will take a series of calculations </span> </p><p><span style="font-family: arial;">The basis to determine which Calendar Year the contains the Fiscal Quarter start - </span><span style="font-family: arial;">if the value is positive the Current Date and the FQ start are in the same calendar year - </span><span style="font-family: arial;">if the value is negative the FQ starts in the prior calendar year</span></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p style="text-align: center;"><span style="font-family: arial;"><b>month([Current Date]) - Min(Int([FY Start Month Parameter]))</b></span></p></blockquote><p><span style="font-family: arial;">The adjustment that will be used in Dateadd function is actually</span></p><p style="text-align: center;"><span style="font-family: arial;"><b>If [Number months Current date and FY Start]>= 0</b></span></p><p style="text-align: center;"><span style="font-family: arial;"><b>then</b></span> <b style="font-family: arial;">[Number months Current date and FY Start] </b></p><p style="text-align: center;"><b style="font-family: arial;">ELSE 12+[Number months Current date and FY Start] end</b></p><p style="text-align: center;"><b style="font-family: arial;"><br /></b></p><p style="text-align: center;"><br /></p><p><span style="font-family: arial;">The FQ for the Current date is </span></p><b style="font-family: arial;"><div style="text-align: center;"><b>If [Month adj to FQ1] <=2 then Dateadd('month',0,[Start Date - Real])</b></div></b><b style="font-family: arial;"><div style="text-align: center;"><b>ELSEIF [Month adj to FQ1] <=5 then Dateadd('month',3,[Start Date - Real])</b></div></b><b style="font-family: arial;"><div style="text-align: center;"><b>ELSEIF [Month adj to FQ1] <=8 then Dateadd('month',6,[Start Date - Real])</b></div></b><b style="font-family: arial;"><div style="text-align: center;"><b>ELSEIF [Month adj to FQ1] <=12 then Dateadd('month',9,[Start Date - Real])</b><b>END</b></div></b><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">For the prior year fiscal year start the formula simply is:</span></p><p><span style="font-family: arial;"></span></p><p style="text-align: center;"><span style="font-family: arial;"><b>Dateadd('year',-1,[Start Date - Real])</b></span></p><p><span style="font-family: arial;">The prior quarter is </span></p><b style="font-family: arial;"><div style="text-align: center;"><b>If [Month adj to FQ1] <=2 then Dateadd('month',-3,[Start Date - Real])</b></div></b><b style="font-family: arial;"><div style="text-align: center;"><b>ELSEIF [Month adj to FQ1] <=5 then Dateadd('month',0,[Start Date - Real])</b></div></b><b style="font-family: arial;"><div style="text-align: center;"><b>ELSEIF [Month adj to FQ1] <=8 then Dateadd('month',3,[Start Date - Real])</b></div></b><b style="font-family: arial;"><div style="text-align: center;"><b>ELSEIF [Month adj to FQ1] <=12 then Dateadd('month',6,[Start Date - Real])</b></div><div style="text-align: center;"><b>END</b></div></b><p><span style="font-family: arial;">The formulas of the YTD QTD prior YTD and Prior QTD are straight forward LODs that total the sales between the period start and end dates</span></p><p><span style="font-family: arial;">YTD sales for the Current Fiscal year</span></p><b><div style="text-align: center;"><b><span style="font-family: arial;">{ FIXED [Order Date]:(if min([Order Date])>=[Current FY start date] </span></b></div><div style="text-align: center;"><b style="font-family: arial; text-align: left;">and min([Order Date])<=[Current Date] then sum([Sales]) end)}</b></div><div style="text-align: center;"><b style="font-family: arial; text-align: left;"><br /></b></div></b></div><div><span style="font-family: arial;">QTD sales in the current FY</span><div><span style="font-family: arial;"><br /></span></div><b style="font-family: arial;"><div style="text-align: center;"><b>{ FIXED [Order Date]:</b></div></b><b style="font-family: arial;"><div style="text-align: center;"><b>If Min([Order Date])>=[Current Q start date] and Min([Order Date])</b></div></b><div style="text-align: center;"><span style="font-family: arial;"><b><=[Current Date] then sum([Sales]) end }</b></span></div><p><span style="font-family: arial;"></span></p><p><b><span style="font-family: arial;"></span></b></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Prior fiscal year YTD sales</span></p></div><b style="font-family: arial;"><div style="text-align: center;"><b>{ FIXED [Order Date]:(if min([Order Date])>=[Prior FY start date] </b></div></b><div style="text-align: center;"><b style="font-family: arial;">and min([Order Date])<=DATEADD('year',-1,[Current Date]) </b></div><div style="text-align: center;"><b style="font-family: arial;">then sum([Sales]) end )}</b></div><div><p><span style="font-family: arial;"></span></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Prior year fiscal quarter sales </span></p><span><div style="font-family: arial; font-weight: bold; text-align: center;"><b>{ FIXED [Order Date]:if Min([Order Date])>=[Prior Q start date] </b></div><div style="font-family: arial; font-weight: bold; text-align: center;"><b>and Min([Order Date])<=DATEADD('month',-3,[Current Date]) then</b></div><div style="font-family: arial; font-weight: bold; text-align: center;"><b>sum([Sales]) end }</b></div><div style="font-family: arial; font-weight: bold; text-align: center;"><b><br /></b></div><div style="font-family: arial;">and the YoY and QoQ formulas are LOD's </div><div style="font-family: arial;"><br /></div><div style="text-align: center;"><span style="font-family: arial;"><b>sum({ FIXED :(sum([Current Year YTD sales])-sum([Prior Year YTD sales ]))})/</b></span></div><div style="text-align: center;"><span style="font-family: arial;"><b>sum({ FIXED : sum([Prior Year YTD sales ])})</b></span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">and </span></div><div style="text-align: center;"><span style="font-family: arial;"><b><br /></b></span></div><div style="text-align: center;"><span style="font-family: arial;"><b>sum({ FIXED :(sum([Current Year QTD sales])-sum([ Prior QTD sales])) })/</b></span></div><div style="text-align: center;"><span style="font-family: arial;"><b>sum({ FIXED :sum([ Prior QTD sales]) })</b></span></div></span><p><span style="font-family: arial;">In table form the user can select the starting dates and the table updates to return the year and quarter to date values </span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWnniNk24IdOFKcnDyWesqwNjL_oY-WVyPG5MB_dVX4LlSPkfPPqL0h7N7EBnjr3VFAB1z3WwSKCCqeFWrup09kveD2rVRdY7bFPRt0yVhZtYiTKXzIbZHij8PAoBazSb6NuOqJjr1RwM/s1920/final+summary+table+ytd+qtd.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWnniNk24IdOFKcnDyWesqwNjL_oY-WVyPG5MB_dVX4LlSPkfPPqL0h7N7EBnjr3VFAB1z3WwSKCCqeFWrup09kveD2rVRdY7bFPRt0yVhZtYiTKXzIbZHij8PAoBazSb6NuOqJjr1RwM/w640-h360/final+summary+table+ytd+qtd.png" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><span style="font-family: arial;">A look at the monthly detail makes it easier to see what the formula do </span><p><span style="font-family: arial;">The current YTD include the months of August - December 5th, QTD is November - December 5th</span></p><p><span style="font-family: arial;">The prior YTD is in FY 17 August 2017 - December 5, 2017 </span><span style="font-family: arial;">and the prior QTD is in FY 18 August 2018 - September5, 2018</span></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><br /></p></blockquote><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF5s_CfY7QUEQ2Bqgtn3_3j7RvPQw-gs22Z2BI1hSWUoYXmuTMcdJgwpwYEOWCUHCcg9tUjrmWc3GLXQ-fq5csy9HXzeuo7ierXuxEFN8wQCZ92aFftJ4o9Wxi9CQmA5KfhW28FWHAr84/s1920/final+detail+at+month+level.png" style="font-family: arial; margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="1080" data-original-width="1920" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF5s_CfY7QUEQ2Bqgtn3_3j7RvPQw-gs22Z2BI1hSWUoYXmuTMcdJgwpwYEOWCUHCcg9tUjrmWc3GLXQ-fq5csy9HXzeuo7ierXuxEFN8wQCZ92aFftJ4o9Wxi9CQmA5KfhW28FWHAr84/w640-h360/final+detail+at+month+level.png" width="640" /></a><br /><p><br /></p><p><br /></p><p><span style="font-family: arial;">Hope it makes sense to you</span></p><p><span style="font-family: arial;">The workbook which contains all the complex formulas can be downloaded at <a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/FAQFiscalYear-toupload/WorkinginFiscalYears" target="_blank">Link to Tableau Public</a></span></p><p><br /></p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Enjoy</span></p><p><span style="font-family: arial;">Jim</span></p></div>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-88189759130984969522020-08-30T08:27:00.005-05:002022-01-24T08:53:31.689-06:00FAQ Series - Business Days<p> </p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p><p><span style="font-family: arial;"><br /></span></p><p><span style="font-family: arial;">Often you only want to use "Business Day" in your viz or move the weekend sales to Friday or Monday -</span></p><p><span style="font-family: arial;"><br /></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7g3hj6LA2DnYpBT3rPjAKm-1lwd46DX5A7prLtBR30LEpsG2Hg5BOfA7gjw9zQ-lqJNJcnZ1maIeds3uVnUm-kXNPo86JMcoerTrZG58OhyphenhyphenPMyasBVxMT2VAo7-IV-oeed84FFTanxek/s1011/landing+page.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="805" data-original-width="1011" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7g3hj6LA2DnYpBT3rPjAKm-1lwd46DX5A7prLtBR30LEpsG2Hg5BOfA7gjw9zQ-lqJNJcnZ1maIeds3uVnUm-kXNPo86JMcoerTrZG58OhyphenhyphenPMyasBVxMT2VAo7-IV-oeed84FFTanxek/s640/landing+page.PNG" width="640" /></a></div><br /><span style="font-family: arial;"><br /></span><p></p><p><span style="font-family: arial;">In the examples here I will us the US standard Sunday - Saturday week with a Monday - Friday "Business Week" - </span></p><p><span style="font-family: arial;"><b>1-Weekday Labels</b></span></p><p><span style="font-family: arial;">Tableau has a couple ways to identify and label dates by the day of the week - </span></p><p><span style="font-family: arial;">A straightforward way is take advantage of the Custom Date option</span></p><p><span style="font-family: arial;">Open the Date dimension - then Custom Date - then Weekdays from the dropdown</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZmW_9ExKGySqTxeDiZs_bguKE6yvFmRj-0ACrZHiScN79hDQkc_uhCeu5pQIpINfJzRIIIsjDRAqRbcjmdVxWZFzzCukQ4pTynjSwUX7bV7T3tAyLgEX5-bWZsN-hM_2pXCmUi4Wu5ck/s1920/Custom+Date+option.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZmW_9ExKGySqTxeDiZs_bguKE6yvFmRj-0ACrZHiScN79hDQkc_uhCeu5pQIpINfJzRIIIsjDRAqRbcjmdVxWZFzzCukQ4pTynjSwUX7bV7T3tAyLgEX5-bWZsN-hM_2pXCmUi4Wu5ck/s640/Custom+Date+option.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><span style="font-family: arial;">Alternately - you can use Datename in a calculated filed - the argument 'weekday' must be the literal as shown in quotes</span><p></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><span style="font-family: arial;">DATENAME('weekday',[Order Date])</span></p></blockquote><p><span style="font-family: arial;">Or use Datepart to assign a number to the weekday - 1 for the first day of the week (Sunday in my examples) and 7 for the last day (Saturday)</span></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><span style="font-family: arial;">DATEPART('weekday',[Order Date]) </span></p></blockquote><p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEju6GFWpefkoQTJLBcRoIu_CR5Frl-0vNX5y-eBsdcdvn5im62jhbwi7CM7ZiTQp-7CX9vPhnB4y6CH_jCIH1w6NGzrPR9OAHy1bA5MzaTodqJqhCOEBonqjUvKfOXPSxdqeADvzahYPIs/s1527/datename+datepart+ex.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="378" data-original-width="1527" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEju6GFWpefkoQTJLBcRoIu_CR5Frl-0vNX5y-eBsdcdvn5im62jhbwi7CM7ZiTQp-7CX9vPhnB4y6CH_jCIH1w6NGzrPR9OAHy1bA5MzaTodqJqhCOEBonqjUvKfOXPSxdqeADvzahYPIs/s640/datename+datepart+ex.PNG" width="640" /></a></div><p> </p><p><span style="font-family: arial;">Sales by day of the week is easy to get - but how to you move the weekend sales to Friday - You can use an "IF ... Then " type of conditional or a Case statement like this</span></p><p><span style="font-family: arial;"><br /></span></p><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><span style="font-family: arial;"><b>CASE [Order Date (Weekdays)]</b></span></p></blockquote></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><span style="font-family: arial;"><b>When 2 then "Monday"</b></span></p></blockquote></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><span style="font-family: arial;"><b>When 3 then "Tuesday"</b></span></p></blockquote></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><span style="font-family: arial;"><b>When 4 then "Wednesday"</b></span></p></blockquote></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><span style="font-family: arial;"><b>When 5 then "Thursday"</b></span></p></blockquote></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><span style="font-family: arial;"><b>Else "Friday-Sunday" End</b></span></p></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><p><br /></p></blockquote></blockquote></blockquote></blockquote><p><span style="font-family: arial;"></span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiunlW2Ua9wI0q2BN09YxgjCrC2YDrYzXiofUUb81SyEvjANgS8FuSaAkJBq89QhyphenhyphenPoTZONvNo9kDa3JpazG1lSdwmnUIRCYuCd5DiSoAPIg3fieMAlH0q7QwrkhqcJXIo47a3bRwIR4ZY/s1146/move+we+to+fri.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="325" data-original-width="1146" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiunlW2Ua9wI0q2BN09YxgjCrC2YDrYzXiofUUb81SyEvjANgS8FuSaAkJBq89QhyphenhyphenPoTZONvNo9kDa3JpazG1lSdwmnUIRCYuCd5DiSoAPIg3fieMAlH0q7QwrkhqcJXIo47a3bRwIR4ZY/s640/move+we+to+fri.PNG" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial; text-align: left;"><br /></span></div><div class="separator" style="clear: both;"><b><span style="font-family: arial;">2- Examples</span></b></div><div class="separator" style="clear: both;"><br /></div><p></p><p></p><div class="separator" style="clear: both;"><span style="font-family: arial;">The day of the week dimension can be used like any other dimension to categorize data - </span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">or in any type of calculation</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><div class="separator" style="clear: both; font-family: "times new roman";"><span style="font-family: arial;">Some use</span><span style="font-family: arial;">rs want to look at how their average sales vary by the day of the week</span></div><div class="separator" style="clear: both; font-family: "times new roman";"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both; font-family: "times new roman";"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYsFAlul2qHw2yC2-cWKMMB6JB6uaSn3D3ODVoXGWWTrtPgnBLbKQjkQSqcNyhHKzuDWwD4OMk7nOotO-2q8FKJwu4OJ5QQCpw34YuPpO-cjHVJN_YSZuX3SLjpwDMBqe2KJSwcnHwvQQ/s970/average+sales+by+dow.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="482" data-original-width="970" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYsFAlul2qHw2yC2-cWKMMB6JB6uaSn3D3ODVoXGWWTrtPgnBLbKQjkQSqcNyhHKzuDWwD4OMk7nOotO-2q8FKJwu4OJ5QQCpw34YuPpO-cjHVJN_YSZuX3SLjpwDMBqe2KJSwcnHwvQQ/s640/average+sales+by+dow.PNG" width="640" /></a></div></div></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"> - Or like this YoY by day of the week - (see <a href="https://jimdehner2.blogspot.com/2019/12/yoy-three-different-approaches.html"> </a></span><a href="https://jimdehner2.blogspot.com/2019/12/yoy-three-different-approaches.html">https://jimdehner2.blogspot.com/2019/12/yoy-three-different-approaches.html</a> <span style="font-family: arial;">)</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhx2M1oehLkS9nY68CFapQoPxNvMr3H5IdXuT9th9z-bwOPxHSuCEnFWpEAJcICDVnMRlvU8A0ZqblGUi_WKlbFMYcpACm0aE4EjWYUj72n62fYwn0vwx1oUzBPIt9n07nvz-E1DyWg1Ps/s1436/yoy+weekday.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="906" data-original-width="1436" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhx2M1oehLkS9nY68CFapQoPxNvMr3H5IdXuT9th9z-bwOPxHSuCEnFWpEAJcICDVnMRlvU8A0ZqblGUi_WKlbFMYcpACm0aE4EjWYUj72n62fYwn0vwx1oUzBPIt9n07nvz-E1DyWg1Ps/s640/yoy+weekday.PNG" width="640" /></a></div><span style="font-family: arial;"><b><br /></b></span></div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><b>3-Holidays</b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><b><br /></b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">Holidays, including those that are unique to region or business culture, often need to be removed from the dataset - </span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">One way is to create a separate dataset of the date and the holiday name:</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaLINefjeKwoWWuj9-PV-q6QyDTmcMj7epJNPbFSi3HFtqAbJybESqooWGeaFhPqbiFjdv4YipAv5wMFlCTi2-DTgDznYRQ_hze4MVwgwRjRyzV6A1wGwJ7GkdSsdT5MlH9zfXo0j5jI8/s316/holiday+schedule.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="128" data-original-width="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaLINefjeKwoWWuj9-PV-q6QyDTmcMj7epJNPbFSi3HFtqAbJybESqooWGeaFhPqbiFjdv4YipAv5wMFlCTi2-DTgDznYRQ_hze4MVwgwRjRyzV6A1wGwJ7GkdSsdT5MlH9zfXo0j5jI8/s0/holiday+schedule.PNG" /></a></div><br /><div style="text-align: left;"><span style="font-family: arial;">Left join the holiday file with your data set on the date field</span></div><div style="text-align: left;"><span style="font-family: arial;"><br /></span></div></div></div><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><div style="text-align: left;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm2MjiB9DNKEExtG2DcxoyWKxcVVJeb3y2CmZ817GVn2AcfWIqgNp-L7qdR83P82OP8n3oW1W_1oXwcN-JOMLuT13ucvBUwFnVd7hvORqN8nx4A1IkuYPVZAVVahfP3i7-RDza2-U2AEU/s847/holiday+left+join.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="506" data-original-width="847" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm2MjiB9DNKEExtG2DcxoyWKxcVVJeb3y2CmZ817GVn2AcfWIqgNp-L7qdR83P82OP8n3oW1W_1oXwcN-JOMLuT13ucvBUwFnVd7hvORqN8nx4A1IkuYPVZAVVahfP3i7-RDza2-U2AEU/s640/holiday+left+join.PNG" width="640" /></a></div><br /><span style="font-family: arial;"><br /></span></div></div></div></blockquote><div class="separator" style="clear: both;"><div class="separator" style="clear: both;"><span style="font-family: arial;">and then use a Data Source filter to delete all the holidays from the data</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><b><br /></b></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1zstYHoVE2t0aRX7HJB4VBcUQQ6mcepw9Teb7e9ZC6R50JGRXls70UP9oQlPb4MBYYK7ZmJdccv839BfV8x7N8vs8iuiG8HAs5JkcCwwP3EvhUEgEm8EubDeIxTFBGUfLGbzmLfvnbow/s1920/datasourcefilter.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1zstYHoVE2t0aRX7HJB4VBcUQQ6mcepw9Teb7e9ZC6R50JGRXls70UP9oQlPb4MBYYK7ZmJdccv839BfV8x7N8vs8iuiG8HAs5JkcCwwP3EvhUEgEm8EubDeIxTFBGUfLGbzmLfvnbow/s640/datasourcefilter.png" width="640" /></a></div><br /> </b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><b><br /></b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><b><br /></b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><b>4-Look back N business days</b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><b><br /></b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">Some users want to find a value in the several days prior to the current day - It can be done easily with a datediff function when all 7 dates are included. But to look back N days excluding weekends is more complex. </span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">The example below is broken into individual formulas that you can combine in your own workbook - also it determines the number of calendar days to look back based on the business need to express the look back in business days - the solution uses actual date values so dimensional filters can be applied without affecting the calculation </span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">First the Lookback period in business days is set using a parameter (just a simple integer)</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu1QHgsrI2o5Pzc3NDzeuwft2uvknvk0yNzXPlL0sMVIucKpNgKXos5a5T-Q0hdvmOpVxOs6ebubBHmTQ4sGGyap-qSyQS4WcO2J-NreVGwU7Al_6U4GUFzhDOaC9CBqAjCQI_B5ufLdA/s557/lookup+back+param.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="283" data-original-width="557" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu1QHgsrI2o5Pzc3NDzeuwft2uvknvk0yNzXPlL0sMVIucKpNgKXos5a5T-Q0hdvmOpVxOs6ebubBHmTQ4sGGyap-qSyQS4WcO2J-NreVGwU7Al_6U4GUFzhDOaC9CBqAjCQI_B5ufLdA/s0/lookup+back+param.PNG" /></a></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><br /></span></div><span style="font-family: arial;"><br /><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">To simplify some of the I wanted to wanted to use Monday as the first day of the week and used the previous Datepart week formula in:</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both;"><span style="font-family: arial;"><b>if [date part weekday]>=1 and [date part weekday]<=7 then</b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><b>[date part weekday]-1 else 0 end</b></span></div></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">You may be tempted to use datepart('weekday',[date],'monday') - unfortunately datepart only supports weekday for weeks that begin on the default - in my case Sunday</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">Next we need the number of 5 day weeks back based on the value of the Business Day Back Parameter - the Min Number of Weeks is:</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b>Int(([Number of day back]+1)/5)</b></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b><br /></b></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b><br /></b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">but that is the number of whole weeks and it needs be adjusted for the position of the date within the week - for that use a function called modulo - the function returns the remainder of the division of the argument (the parameter value +1) divided by 5 </span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b>([Number of day back]+1)%5</b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">The total number of weekend then is</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"> </span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b><div class="separator" style="clear: both;"><div class="separator" style="clear: both;">{ FIXED [Order Date]:(</div><div class="separator" style="clear: both;">if min([jd datepart start monday])=0 then Min([JD Number of weeks ] )</div><div class="separator" style="clear: both;">elseif min([jd datepart start monday])<int(Min([jd modulo day of week]))</div><div class="separator" style="clear: both;">then Min([JD Number of weeks ])+1 else Min([JD Number of weeks ] )end ) }</div></div></b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">The formula used to add in the Saturday/Sunday weekend days to the Business Days Back parameter to determine the number of calendar days to use in the date diff calculation</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b>int(min([Number of day back])) + 2*(min([number of weekend days]))</b></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b><br /></b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">finally the calendar date for N Business days in the past can be determined as</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b>{ FIXED [Order Date] :DATE(dateadd('day',-[JD number of dates back],Min([Order Date]))) }</b></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b><br /></b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">For example using December 2019 Superstore data looking back 7 business days would return :</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCYEuYJY3nRxmtAM-d34_7WVAsksX0nxUojMJxudJWhkvNN80EMVEfzhqx86tFVBa6bKf5IgvMx1MveMwXKodLMTdke_hBEa-qvXACTPkii1GHCMaM0AIAgnLrrxLNIhyphenhyphenDNAHX5t64rrY/s1920/results+-+lookback.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1080" data-original-width="1920" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCYEuYJY3nRxmtAM-d34_7WVAsksX0nxUojMJxudJWhkvNN80EMVEfzhqx86tFVBa6bKf5IgvMx1MveMwXKodLMTdke_hBEa-qvXACTPkii1GHCMaM0AIAgnLrrxLNIhyphenhyphenDNAHX5t64rrY/s640/results+-+lookback.png" width="640" /></a></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div>Great but real business questions are usually about the growth from the over the period or the total sales looking back over all the dates. To get that we need a start date and a parameter. First determine and fix the calendar date based on the start date and the number of business days to look back</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><div style="text-align: center;"><span style="font-family: arial;"><b>{ FIXED : min(if [Enter start date]=[Order Date] then [JD date of back dated] end )}</b></span></div><div style="text-align: center;"><span style="font-family: arial;"><b><br /></b></span></div><div><span style="font-family: arial;">then the value on that date becomes:</span></div><div><span style="font-family: arial;"><br /></span></div><div style="text-align: center;"><span style="font-family: arial;"><b>IFNULL({ FIXED :sum(if [JD Fixed back date from param]= </b></span></div><div style="text-align: center;"><span style="font-family: arial;"><b>[Order Date] then [Sales] end)} ,0)</b></span></div><div style="text-align: center;"><br /></div><span style="font-family: arial;"> </span></div><span style="font-family: arial;">The ifnull adjust for dates where there were no sales</span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><br /></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;">The value on Start Date is simply</span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial;"><b><br /></b></span></div><div class="separator" style="clear: both;"><span style="font-family: arial;"><div class="separator" style="clear: both; font-weight: bold; text-align: center;">IFNULL({ FIXED [Order Date]: sum( if DATETRUNC('day',[Order Date]) = </div><div class="separator" style="clear: both; font-weight: bold; text-align: center;">DATETRUNC('day',[Enter start date]) then [Sales] end )} ,0)</div><div class="separator" style="clear: both; font-weight: bold; text-align: center;"><br /></div><div class="separator" style="clear: both;">And the percent difference is:</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; font-weight: bold;">If (sum([JD value at lookback date]))=0 then 1 </div><div class="separator" style="clear: both; font-weight: bold;">elseif (sum([jd value on start date parameter value]))=0 then 0</div><div class="separator" style="clear: both; font-weight: bold;">else(sum([jd value on start date parameter value])- sum([JD value at lookback date]))/sum([JD value at lookback date])</div><div class="separator" style="clear: both; font-weight: bold;">end</div><div class="separator" style="clear: both; font-weight: bold;"><br /></div><div class="separator" style="clear: both; font-weight: bold;"><br /></div><div class="separator" style="clear: both; text-align: left;">All the calculations are LOD's and can be used to create a simple summary table </div><div class="separator" style="clear: both; text-align: left;"><b><br /></b></div><div class="separator" style="clear: both; text-align: left;"><div class="separator" style="clear: both; font-weight: bold; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUeCLvx3-ym5_Ap_p5jfTlBEBQL0A86N4YhPjJB-_NVllcXe9N8ZCT3kpW7uFJAV4Y36N2XWZhn8B_PtZQeluDf65l9xPvM7OOBJCMcz-e_iTS4jCIb6bj-6jgiqdp9oIJ3VwTv4NHtIk/s773/BAN+Percent+Difference+Lookback.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="669" data-original-width="773" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUeCLvx3-ym5_Ap_p5jfTlBEBQL0A86N4YhPjJB-_NVllcXe9N8ZCT3kpW7uFJAV4Y36N2XWZhn8B_PtZQeluDf65l9xPvM7OOBJCMcz-e_iTS4jCIb6bj-6jgiqdp9oIJ3VwTv4NHtIk/s640/BAN+Percent+Difference+Lookback.PNG" width="640" /></a></div><div class="separator" style="clear: both; font-weight: bold; text-align: center;"><br /></div><div class="separator" style="clear: both; font-weight: bold; text-align: center;"><br /></div><div class="separator" style="clear: both;">Determining the the total sales over the "lookback period" will require another LOD</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both;"><b>IFNULL({ FIXED :sum(</b></div><div class="separator" style="clear: both;"><b>if [JD Fixed back date from param]<= [Order Date] and </b></div><div class="separator" style="clear: both;"><b>[Order Date]<=[Enter start date]</b></div><div class="separator" style="clear: both;"><b>then [Sales] end)} ,0)</b></div></div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8wBYj0OzUFhvWGM6k0NKeqBDgXSIGv_idN_SGeDJ35PQDTti__siNcWVPK-haagTnzWw8kxRNWrRY-JN5_4D2b6bGzh3lyHQXVrEv-1P46qRQud6b_7FqhDX-HO9DJsyJnXUW7tSqEEk/s771/total+over+look+back+period.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="607" data-original-width="771" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8wBYj0OzUFhvWGM6k0NKeqBDgXSIGv_idN_SGeDJ35PQDTti__siNcWVPK-haagTnzWw8kxRNWrRY-JN5_4D2b6bGzh3lyHQXVrEv-1P46qRQud6b_7FqhDX-HO9DJsyJnXUW7tSqEEk/s640/total+over+look+back+period.PNG" width="640" /></a></div><br /><div class="separator" style="clear: both;">Lots of LOD's and can be confusing but necessary to avoid table calculations which are based on a position in a table and not an actual date. </div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">There could be many more examples and variations on viewing sales by business day. I encourage you to try some of your own - </div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">The examples here are captured in a workbook that has been posted to my public site at </div><div class="separator" style="clear: both;"><a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/Salesbyweekday/Dashboard1">https://public.tableau.com/profile/jim.dehner#!/vizhome/Salesbyweekday/Dashboard1</a> </div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Jim</div><div class="separator" style="clear: both;"><br /></div><b> </b></div></div></span></div>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-7288293684542479102020-07-12T13:10:00.002-05:002020-07-12T13:23:47.631-05:00FAQ Series - Duration and Time - Not the same thing<div><font face="arial">Recently there have been a number of Forum questions on converting time to duration </font></div><div><font face="arial"><br /></font></div><div><font face="arial">Time and duration are not the same - Time can be read from a clock - duration is the accumulation on intervals - and although we use a common terminology - hours - minutes and seconds they are different </font></div><div><font face="arial"><br /></font></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8ZybdeRpqyoRSbL0VK_dA4CzO6PFhU-6JlojUBSyF32U8PmsRgETYeGRfzuW1lXG7rGpBK6lOGeO-uFTA4ij2ucwgdUX3dsd2wa_UF2rGH6GdMAnoRcf7Ui6MzIsAOUAblQiiOyfSk-4/s1283/face+plate.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="717" data-original-width="1283" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8ZybdeRpqyoRSbL0VK_dA4CzO6PFhU-6JlojUBSyF32U8PmsRgETYeGRfzuW1lXG7rGpBK6lOGeO-uFTA4ij2ucwgdUX3dsd2wa_UF2rGH6GdMAnoRcf7Ui6MzIsAOUAblQiiOyfSk-4/w400-h224/face+plate.PNG" width="400" /></a></div><font face="arial"><br /></font></div><div><font face="arial"><br /></font></div><div><font face="arial"><br /></font></div><div><font face="arial">This example uses a simple data set consisting of project start and end times by employee</font></div><div><font face="arial"><br /></font></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTg6UPsUAGlqsHXniAHiB2oF9UwuS_Hb2nPQEejIvGDA6DAUfWn0kbrgyL3oi_65zs9giBxYR4RgAFXZlQPnvtMk_KeUNp32R29rLHPNf5TG29mQsvqzf2oXT0xPRAHriInoTlrQ4Zdxs/s631/excel+data+file.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="370" data-original-width="631" height="235" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTg6UPsUAGlqsHXniAHiB2oF9UwuS_Hb2nPQEejIvGDA6DAUfWn0kbrgyL3oi_65zs9giBxYR4RgAFXZlQPnvtMk_KeUNp32R29rLHPNf5TG29mQsvqzf2oXT0xPRAHriInoTlrQ4Zdxs/w400-h235/excel+data+file.PNG" width="400" /></a></div><font face="arial"><br /></font></div><div><font face="arial"><br /></font></div><div><font face="arial"><b>Date Functions - </b><font size="2">(see </font></font><a href="https://jimdehner2.blogspot.com/2020/02/dates-functions-and-other-necessary.html">https://jimdehner2.blogspot.com/2020/02/dates-functions-and-other-necessary.html</a>)</div><div><font face="arial"><br /></font></div><div><font face="arial">The date functions in Tableau are based on a truncating the date/time structure shown below </font></div><div><font face="arial"><br /></font></div><div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYaraTxQnpjCu0AAg1iCFjoKrrU4ZKPO8Qc418H3zS4snUPsxiH3RkJ2H1FcWb6YlMarEQtl2tZssFGih-CZ8rEFqygrwbNAkKHebvIsI6Nypte3i6w-AeawWOeazb8bMzfgClFW8bkxw/s1713/correct+chevron.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="363" data-original-width="1713" height="106" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYaraTxQnpjCu0AAg1iCFjoKrrU4ZKPO8Qc418H3zS4snUPsxiH3RkJ2H1FcWb6YlMarEQtl2tZssFGih-CZ8rEFqygrwbNAkKHebvIsI6Nypte3i6w-AeawWOeazb8bMzfgClFW8bkxw/w500-h106/correct+chevron.png" width="500" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><font face="arial"><br /></font></div><div><br /></div><div><font face="arial">If you needed to determine the number of days between the start and end dates you could use </font></div><div style="text-align: center;"><font face="arial"><b> Datediff('day',[Start date],[End date]) </b></font></div><div><font face="arial"><br /></font></div><div><font face="arial"> and the value for project A9 would be - 27</font></div><div><font face="arial"><br /></font></div><div><font face="arial"><br /></font></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYzjM1utTr3ljrsYLsBAbwTv1kf_jzU8szkgDDpk3FwxbN9qcYbBYpLSduDT64tlWRicIKp4VOmrp4WLyzOhZoLGa4qRrxWD4_-qxq8W2Ql_Tbda695AWyn8HhtllRyR48V2iw2XtcT-k/s837/p9+27.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="240" data-original-width="837" height="144" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYzjM1utTr3ljrsYLsBAbwTv1kf_jzU8szkgDDpk3FwxbN9qcYbBYpLSduDT64tlWRicIKp4VOmrp4WLyzOhZoLGa4qRrxWD4_-qxq8W2Ql_Tbda695AWyn8HhtllRyR48V2iw2XtcT-k/w500-h144/p9+27.PNG" width="500" /></a></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><font face="arial">but the actual interval is 27 days 1 hour 1 minute and 32 minutes </font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><font face="arial">Increasing the number of decimal places will not change the result - Datediff truncated the value at the 'day' level</font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNx3H5j8RCisaUJDslDQSIesjO6v-LZQVPgcszPFabtil5YDQj3xnFp92K2meHke_eP8az4n2WZg0nWmzkpwDfKBfYix8QvJBkTSHBSj2RpOU8DLVezblkx4SHQXZD5aCV-g12SnHN50E/s998/pr+increas+decimal.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="374" data-original-width="998" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNx3H5j8RCisaUJDslDQSIesjO6v-LZQVPgcszPFabtil5YDQj3xnFp92K2meHke_eP8az4n2WZg0nWmzkpwDfKBfYix8QvJBkTSHBSj2RpOU8DLVezblkx4SHQXZD5aCV-g12SnHN50E/s320/pr+increas+decimal.PNG" width="320" /></a></div><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><font face="arial">So how can we get Tableau to return the actual duration - </font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><font face="arial"><b>Determining the duration</b></font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><font face="arial">The solution is to build the duration from the lowest level (grain) in the data - the example here is in seconds - Yours may differ and you can adjust the model as needed - also we will want to be able to calculate the duration at different levels in the data - this LOD will meet that need</font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; text-align: center;"><font face="arial"><b>{ INCLUDE [Employee],[Project]:sum( DATEDIFF('second',[Start Date],[End Date]) )}</b></font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><font face="arial">The LOD will return the difference in seconds - </font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM31oUINEghTUiMU-uFKKNrnHPqYXIA8dCE6gyO83LZzNczu8OJaawVpWhzKLroUFvGI7NpDFVAfcb2uzKT8daF_bilbTMmxPSa93qmOGvDaLHrff85-ctFKynoSTndo3_7bW9ZV7JUGQ/s845/lod+totals+at+second+level.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="500" data-original-width="845" height="295" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM31oUINEghTUiMU-uFKKNrnHPqYXIA8dCE6gyO83LZzNczu8OJaawVpWhzKLroUFvGI7NpDFVAfcb2uzKT8daF_bilbTMmxPSa93qmOGvDaLHrff85-ctFKynoSTndo3_7bW9ZV7JUGQ/w500-h295/lod+totals+at+second+level.PNG" width="500" /></a></div><div class="separator" style="clear: both; text-align: center;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; text-align: center;"><font face="arial"><br /></font></div></div><div class="separator" style="clear: both;"><font face="arial">The duration are large and not what you want. They need to be converted to hours, minutes, and seconds </font></div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><font face="arial">The Duration in Seconds is </font></div><div><font face="arial"><br /></font></div><div style="text-align: center;"><font face="arial"><b>sum({ INCLUDE [Employee],[Project]:sum([datediff at the second LOD]%60)})%60</b></font></div><div style="text-align: center;"><font face="arial"><b><br /></b></font></div><div><font face="arial">Again using an LOD to allow summing at different levels in the data - Note the use of <b>MODULO</b> - the function returns the remainder of the measure (here the total seconds) divided by the value that follows the % sign (60) - the LOD will first sum the remaining seconds at the level of the viz - the second use of modulo converts the total to minutes and seconds during the accumulation across the employee level and above.</font></div><div><font face="arial"><br /></font></div><div><font face="arial">The Duration in Minutes is </font></div><div><font face="arial"><br /></font></div><div style="text-align: center;"><font face="arial"><b>int(sum({ INCLUDE [Employee],[Project]:sum([datediff at the second LOD])/60 }) %60)</b></font></div><div style="text-align: center;"><font face="arial"><b><br /></b></font></div><div><font face="arial">The Int() or Floor() will returns the integer portion of the calculation rounded down </font></div><div><font face="arial"><br /></font></div><div><font face="arial">The Duration in Days is</font></div><div><font face="arial"><br /></font></div><div style="text-align: center;"><font face="arial"><b>int(sum({ INCLUDE [Employee],[Project]:sum([datediff at the second LOD]) }) / (60*60*24))</b></font></div><div style="text-align: center;"><font face="arial"><b><br /></b></font></div><div><font face="arial"><b><br /></b></font></div><div><font face="arial">In text table form the viz is</font></div><div><font face="arial"><br /></font></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGzKhTVWa17wRtzPutTD9IBkpw8f4F37BbvbULO8d0CnP5Tx0h8kZtz8DW77ia2e2WQ940Y_VHBm77h9-zUeN3689PyiH5J4LvDT5OG9n3M0uIBHe2P75OFTGLpG3dcBaPOUWbPdufOSk/s1373/detail+duration+text+table.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="601" data-original-width="1373" height="274" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGzKhTVWa17wRtzPutTD9IBkpw8f4F37BbvbULO8d0CnP5Tx0h8kZtz8DW77ia2e2WQ940Y_VHBm77h9-zUeN3689PyiH5J4LvDT5OG9n3M0uIBHe2P75OFTGLpG3dcBaPOUWbPdufOSk/w625-h274/detail+duration+text+table.PNG" width="625" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><font face="arial">Or in summary </font></div><div><font face="arial"><br /></font></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxZu8vE5AcqTFB-Ms6-fGdoGn-tRBvfDwoyhyQKyNuAdcVo6vz8d5BL5_GkZqpE4jCIjrphr6SyKDA_iE3EgZaot-uU8_nkGfzkMiv4OczmxkxUPEMgT2WjA9IPub3tcEr28N0KW6PyPE/s1014/text+table+summary.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="651" data-original-width="1014" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxZu8vE5AcqTFB-Ms6-fGdoGn-tRBvfDwoyhyQKyNuAdcVo6vz8d5BL5_GkZqpE4jCIjrphr6SyKDA_iE3EgZaot-uU8_nkGfzkMiv4OczmxkxUPEMgT2WjA9IPub3tcEr28N0KW6PyPE/w625-h400/text+table+summary.PNG" width="625" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><font face="arial"><br /></font></div><div><font face="arial"><b>Format dd:hh:mm:ss</b></font></div><div><font face="arial"><b><br /></b></font></div><div><font face="arial">Often users have asked to have a format similar to dd:hh:mm:ss</font></div><div><br /></div><div><font face="arial"><br /></font></div><div><font face="arial"><br /></font></div><div style="text-align: center;"><font face="arial"><b>str([duration days])+":" +str([duration hours])+":" +str([duration minutes])+":" +str([duration - seconds] )</b></font></div><div><font face="arial"><b><br /></b></font></div><div><span style="font-family: arial;">The formula leverages the integer value in the LOD (integer) values and converting them to strings </span></div><div><span style="font-family: arial;"><br /></span></div><div><span style="font-family: arial;">and returns this in summary </span></div><div><span style="font-family: arial;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9PL1pT7CAfjKB_bU0Q7X3HY3D376IXVC4WVvfdPSJHcQTHx-Oz_3gwjogHqo5H-PNmL2MgUtSkgOMa-EHn2-kP1nhbDO8Z_zRdnfBkMh4GZI0PxQo4QEHA4FMUjAiAgDmdwS3fozIc-A/s845/time+format+summary.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="403" data-original-width="845" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9PL1pT7CAfjKB_bU0Q7X3HY3D376IXVC4WVvfdPSJHcQTHx-Oz_3gwjogHqo5H-PNmL2MgUtSkgOMa-EHn2-kP1nhbDO8Z_zRdnfBkMh4GZI0PxQo4QEHA4FMUjAiAgDmdwS3fozIc-A/w500-h239/time+format+summary.PNG" width="500" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;"><font face="arial">Time and duration are not the same and it does take a few steps to getthe actual duration in a format the user expects - Hope this helps the next time you are faced with a similar problem</font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><font face="arial">The workbook used in these examples can be found at </font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/Durationintimeformat/Dashboard1">https://public.tableau.com/profile/jim.dehner#!/vizhome/Durationintimeformat/Dashboard1</a></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><font face="arial">Enjoy</font></div><div class="separator" style="clear: both;"><font face="arial"><br /></font></div><div class="separator" style="clear: both;"><font face="arial">Jim </font></div><span style="font-family: arial;"><br /></span></div>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-81809354821883499812020-06-21T11:41:00.000-05:002020-06-21T11:41:03.193-05:00FAQ Series - Context filter - What do they really do?<p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">In Tableau , like other languages, the sequence that filters or calculations are executed is controlled by the Order of Operations. The order starts with 3 filters – Extract filters limit the data passing from the data source to tableau, Data Source filters further limit data available in the workbook and can be specific to values within dimensions, and Context filters limit the data available to the remainder of the calculations, sets, Top N, dimension or measure filters or table calculations<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3BmUoXpFi4uxwYbaOJKg8TG_vO9gUk2Rmeuzwp9fRARewbCk4csDBgLek5JPV5VHM9z-FPuiZxCLQbthf6W_4ngKcNAuhVURKvJrf9OmFDMVbdZfLfa31oY-cXfnPnxMzKS8_qon879U/s1118/New+OOO+slide.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="700" data-original-width="1118" height="391" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3BmUoXpFi4uxwYbaOJKg8TG_vO9gUk2Rmeuzwp9fRARewbCk4csDBgLek5JPV5VHM9z-FPuiZxCLQbthf6W_4ngKcNAuhVURKvJrf9OmFDMVbdZfLfa31oY-cXfnPnxMzKS8_qon879U/w625-h391/New+OOO+slide.PNG" width="625" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">But how exactly do context filters affect Top N and LOD expressions<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">The Context filters are applied in the step prior to creating sets, setting Top N filters and performing LOD calculations.<span style="mso-spacerun: yes;"> </span>When a dimension is “placed in Context” and then the values are only the “un-filtered” data is available in the LOD or the Top N calculations<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">Let’s look at an example using an LOD with Superstore data using a Fixed expression that combines segments and category:<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNN10ziuiXCTxu3_EFMSquKGBAV4JOjWEMdDhMty2Lk28tAGM_FGa_S4aVij0XJ72tqkImuEoeb3grZJ3NNKqYBP4Xz8m5JZtmA55ovDvvzFFWOCVE7PK-rt6MRtq5m3Sepu0pVrLJcVg/s737/New+fixed+lod+sales.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="141" data-original-width="737" height="95" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNN10ziuiXCTxu3_EFMSquKGBAV4JOjWEMdDhMty2Lk28tAGM_FGa_S4aVij0XJ72tqkImuEoeb3grZJ3NNKqYBP4Xz8m5JZtmA55ovDvvzFFWOCVE7PK-rt6MRtq5m3Sepu0pVrLJcVg/w500-h95/New+fixed+lod+sales.PNG" width="500" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><p></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">And a very simple text table viz:<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHp9rdb9va_czdbDlOLfgGcYMcSl_Hnh6mWuJeJNbWinIWnJl-1qxdldreQkDx3HT1OgVq_Aq7lyegPN8NWdulQzXc6OyNZ6EhgiABo83y63vOhWzOTINHLARMnFVgs_M1wUk0FtsQRDQ/s841/New+no+filter+table.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="376" data-original-width="841" height="280" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHp9rdb9va_czdbDlOLfgGcYMcSl_Hnh6mWuJeJNbWinIWnJl-1qxdldreQkDx3HT1OgVq_Aq7lyegPN8NWdulQzXc6OyNZ6EhgiABo83y63vOhWzOTINHLARMnFVgs_M1wUk0FtsQRDQ/w625-h280/New+no+filter+table.PNG" width="625" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">Now apply a filter on Region and see the affect of the context filter<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">First filter out Central region with a normal dimension filter (after the context filter and the LOD expression are applied).<span style="mso-spacerun: yes;"> </span>The results have not changed – the filter did not affect the LOD results (Often referred to as “Ignoring the filter”)<span style="mso-spacerun: yes;"> </span><o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"><br /></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4GId22YrwZqhJ0NUj5hGpDBL_bpdlywmuuNsiHNlw2PNLQPTw8AJoVqk_dZ9UZthNsdhGfRzR-hLy7PC3eumweq7KoKZEfffPrTKU_zlEMV6BqT9BIs1dk7PX-Lry9994Q0uo9UdOEVI/s777/new+lod+not+in+context.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="777" height="344" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4GId22YrwZqhJ0NUj5hGpDBL_bpdlywmuuNsiHNlw2PNLQPTw8AJoVqk_dZ9UZthNsdhGfRzR-hLy7PC3eumweq7KoKZEfffPrTKU_zlEMV6BqT9BIs1dk7PX-Lry9994Q0uo9UdOEVI/w500-h344/new+lod+not+in+context.PNG" width="500" /></a></div><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">Now place the region filter in Context so it is applied before the LOD is calculated:<span style="mso-spacerun: yes;"> </span>And as expected the results from the LOD are now changed (they don’t include the Central region that was filtered out by the Context Region filter)</span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLUOlORaZ9pCZfOMzeUCiHJfDdooei9sC_B6OUWp1sB2WuFsIydcwdizzCYkoJCpIcliPShTB6LARbR56fSr3QHxRl1IZ8nxq9Krotee5_KTtNmvogyShyphenhyphenwqcLYzsSmWer5dH4v5Rw4uk/s807/New+LOD+in+context.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="540" data-original-width="807" height="335" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLUOlORaZ9pCZfOMzeUCiHJfDdooei9sC_B6OUWp1sB2WuFsIydcwdizzCYkoJCpIcliPShTB6LARbR56fSr3QHxRl1IZ8nxq9Krotee5_KTtNmvogyShyphenhyphenwqcLYzsSmWer5dH4v5Rw4uk/w500-h335/New+LOD+in+context.PNG" width="500" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><b><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">Top N Filters<o:p></o:p></span></b></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><b><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></b></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">The Top N filter option on sets and dimensional filters are also affected by the placement of a dimension in Context<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">Superstore data will be used in the example and the Top N option will be used on Sub-categories<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; text-align: center;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGYvFaDsC4zVZc4rRktm678jwz4uNV_ddQq05IhpFXFOM9_KF2C5SuVjqWIizlaClrOPEHB4x2eVEMCJwjiGxSaw36PzvdzVWV8oyHvNLNkbifm0gvzUW1KAWIq8BnVp_ENuWHq3RNvik/s565/New+top+n+setup.PNG" style="font-family: arial, sans-serif; font-size: 16px; margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="565" data-original-width="458" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGYvFaDsC4zVZc4rRktm678jwz4uNV_ddQq05IhpFXFOM9_KF2C5SuVjqWIizlaClrOPEHB4x2eVEMCJwjiGxSaw36PzvdzVWV8oyHvNLNkbifm0gvzUW1KAWIq8BnVp_ENuWHq3RNvik/w324-h400/New+top+n+setup.PNG" width="324" /></a></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">Applying the filter on a text table and using year on columns results in<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwebhlApwSRQqTKPw7ZMWDSYPQaLJPBxSDYYPao_WDeN-AQS1nPBO7fTQiRxO_dR-TImjEA3EEvlqliy2XMSPydTdddrx2A0ks2mPTooENPs1htFRYZIpxXqHMGKtAaqxGasWXtHWqi7s/s818/new+top+N+not+context.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="393" data-original-width="818" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwebhlApwSRQqTKPw7ZMWDSYPQaLJPBxSDYYPao_WDeN-AQS1nPBO7fTQiRxO_dR-TImjEA3EEvlqliy2XMSPydTdddrx2A0ks2mPTooENPs1htFRYZIpxXqHMGKtAaqxGasWXtHWqi7s/w500-h241/new+top+N+not+context.PNG" width="500" /></a></div><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">Out of context the East region is removed but the Top 3 sub-categories are unchanged -<span style="mso-spacerun: yes;"> </span>That is because the Top N were determined before the dimension filter was applied<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt;"><br /></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt;"></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEAJnXYXLw8K-aGfwDCYnlTW5fpLlT3mQMUOtmv-ba3LQM-Ddyj5crIhhGZVg60Z9otU_CQ_zqtq7N6nd20CEky9-xu6CQ0Q3FpzM-AAExfzrhAOT0c_egf3-Tqhe5h4pteMeKGBh3idY/s811/new+east+filtered+no+context.PNG" style="font-family: "times new roman"; margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="555" data-original-width="811" height="343" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEAJnXYXLw8K-aGfwDCYnlTW5fpLlT3mQMUOtmv-ba3LQM-Ddyj5crIhhGZVg60Z9otU_CQ_zqtq7N6nd20CEky9-xu6CQ0Q3FpzM-AAExfzrhAOT0c_egf3-Tqhe5h4pteMeKGBh3idY/w500-h343/new+east+filtered+no+context.PNG" width="500" /></a></div> <p></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">When Region is placed in context the East region is again removed but Tables now replace Storage – The Top 3 Total across the 3 regions are now Chairs, Phones and Tables – the East region was filtered out of the data in the Context filter before the Top N was determined.<span style="mso-spacerun: yes;"> </span>Note also the values or Chairs and Phones in the other regions remains unchanged -<span style="mso-spacerun: yes;"> </span><o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"><br /></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; text-align: center;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYYaW4aEuqalXOSyPxJzqO0q4c4lfD2KsDwGXjTovW622b7l_3HEumMrs4g-lc7K56CnZnsY8xBi5CGyRryAe5tZctjUTVBrlrmM6vxjIpjQWQIlBeVFK3O7zOogWTqXYQGhy1yhV9uKw/s1093/new+top+n+in+context.PNG" style="font-family: arial, sans-serif; font-size: 16px; margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="554" data-original-width="1093" height="254" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYYaW4aEuqalXOSyPxJzqO0q4c4lfD2KsDwGXjTovW622b7l_3HEumMrs4g-lc7K56CnZnsY8xBi5CGyRryAe5tZctjUTVBrlrmM6vxjIpjQWQIlBeVFK3O7zOogWTqXYQGhy1yhV9uKw/w500-h254/new+top+n+in+context.PNG" width="500" /></a></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; text-align: center;"><br /></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">The total across the 3 regions is calculated for each sub-category and it is the 3-region total that is used to determine the Top N</span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">That may not be what you wanted – How would you determine the Top N subcategories based on their sales in each Region independently</span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;">That solution will required the use on an LOD and a Ranking function –<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"> </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman"; mso-no-proof: yes;"><o:p></o:p></span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_4jJ3ph9OlfmtD31qL9-XHKE4AEj6OZwv_tQXXCod1KRtnaKcjzRXBcq-QckBqPMQcxMTRD9uaJ091AX8HhCO31ZZbSPmv-pvGMNP_sHRAoYeYlqIQgcks3Z1QlAUPmruzt9jAKJUhkI/s809/New+lod+sales+region+subcat.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="197" data-original-width="809" height="154" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_4jJ3ph9OlfmtD31qL9-XHKE4AEj6OZwv_tQXXCod1KRtnaKcjzRXBcq-QckBqPMQcxMTRD9uaJ091AX8HhCO31ZZbSPmv-pvGMNP_sHRAoYeYlqIQgcks3Z1QlAUPmruzt9jAKJUhkI/w625-h154/New+lod+sales+region+subcat.PNG" width="625" /></a></div><p></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">And<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; text-align: center;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5HgMmak3t8GtvMNZEaSLxsJaV7qrNe6aQIHVGtEIzPTt2C2KRLo52xpv3mQdvXohglB2I7_vfpV5ypkpqCvlYBIxizCDIjvO9tI2-SoL5MoBn-c118jeJp-XELh5UlC-E8rVbWrmXFow/s822/New+Rank+sales+region+sub+cat.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="193" data-original-width="822" height="118" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5HgMmak3t8GtvMNZEaSLxsJaV7qrNe6aQIHVGtEIzPTt2C2KRLo52xpv3mQdvXohglB2I7_vfpV5ypkpqCvlYBIxizCDIjvO9tI2-SoL5MoBn-c118jeJp-XELh5UlC-E8rVbWrmXFow/w500-h118/New+Rank+sales+region+sub+cat.PNG" width="500" /></a></div><p></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">And a Filter based on the Rank<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; text-align: center;"> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicyQgqwZsivC6rOC_4_jl1k_gabKPR0HB2QQoZoewZ2GZdGLqjxvCJ106_69Zpqu_KR_CMEZIU5F9meN2RVlt_a7yKjXQ8EveYWSK2_I8p7dA7XBct5ou7AvFJw8cm1qqz-xkj17_i9b0/s685/New+Rank+LOD+filter.PNG" style="font-family: arial, sans-serif; font-size: 16px; margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="233" data-original-width="685" height="170" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicyQgqwZsivC6rOC_4_jl1k_gabKPR0HB2QQoZoewZ2GZdGLqjxvCJ106_69Zpqu_KR_CMEZIU5F9meN2RVlt_a7yKjXQ8EveYWSK2_I8p7dA7XBct5ou7AvFJw8cm1qqz-xkj17_i9b0/w500-h170/New+Rank+LOD+filter.PNG" width="500" /></a></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">The LOD determines the sub-category sales in each region and then the Rank (a table calculation ) is applied<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJDNTEK19-9_G5LUDd05eCltxkNqpy0LkMXH07jH-8jg7Ozs_8r72n4TnwGfCcxVwQ6KPVYvnbkRd20jbfZi71eagsCxf_cumPQFfblV-oN_vjhVKOov16N65nAbEvWbVKKtlflChNlac/s1402/new+nested+sort+top+n+all+regions.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="406" data-original-width="1402" height="145" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJDNTEK19-9_G5LUDd05eCltxkNqpy0LkMXH07jH-8jg7Ozs_8r72n4TnwGfCcxVwQ6KPVYvnbkRd20jbfZi71eagsCxf_cumPQFfblV-oN_vjhVKOov16N65nAbEvWbVKKtlflChNlac/w500-h145/new+nested+sort+top+n+all+regions.PNG" width="500" /></a></div><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">And filtering the East region removes if from the chart without affecting the top 3 determined by the rank in the other regions<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV4sEvR9SHoDOoSZl0qL_9ViueVJW_XRCsa8WJNf9C9l0cFjOyE2knsUsDzVw3ZvuTF4UWaE-OFHsYTH6h5hgtGC_FUQA3rsaFV5KzhDKkmSQFXjjDvvqzAXRtYp8ObLWa8ddhYCnr2DI/s1382/New+nest+sort+filtered+east.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="591" data-original-width="1382" height="214" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV4sEvR9SHoDOoSZl0qL_9ViueVJW_XRCsa8WJNf9C9l0cFjOyE2knsUsDzVw3ZvuTF4UWaE-OFHsYTH6h5hgtGC_FUQA3rsaFV5KzhDKkmSQFXjjDvvqzAXRtYp8ObLWa8ddhYCnr2DI/w500-h214/New+nest+sort+filtered+east.PNG" width="500" /></a></div><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span><p></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">Placing a dimension in the Context filter is a decision that you control – it changes the order in which filters are applied to the data table and the calculation results.<span style="mso-spacerun: yes;"> </span>Make your decision on how you want the filter to act.<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">It may take a little practice, but you will get there in no time.<o:p></o:p></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"><br /></span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";">A downloadable workbook containing these examples can be found at :</span></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><span style="font-family: arial, sans-serif; font-size: 12pt; mso-fareast-font-family: "Times New Roman";"> </span><a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/ContexFilters/ContextFilters">https://public.tableau.com/profile/jim.dehner#!/vizhome/ContexFilters/ContextFilters</a> </p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><br /></p><p class="MsoNormal" style="line-height: normal; margin-bottom: 0in;"><font face="arial">Jim</font></p><div><font face="arial"><br /></font></div>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-56693892821300293682020-06-12T12:02:00.003-05:002022-01-24T08:53:44.874-06:00FAQ - Convert String Dates<blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p class="MsoNormal"><font face="arial"></font></p><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p><p class="MsoNormal"><font face="arial"><br /></font></p><p class="MsoNormal"><font face="arial">Dates are a special data type in Tableau the unique properties of being self-sequencing, sorting and can be used in date functions to set ranges, filter and aggregations. But some legacy systems or public sources sometimes cast dates as a single string or individual strings for each date part. Working with “real date” is much easier and converting strings to date is really not that difficult.<o:p></o:p></font></p><p class="MsoNormal"><font face="arial">First – how do you know if your date is really text –<o:p></o:p></font></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial">Open the Data Source Tab – the data may look like a date but if the Data Type is ABC then it has been loaded as a String<o:p></o:p></font></p><p class="MsoNormal"><br /></p><div class="separator" style="clear: both; text-align: center;"><span style="font-family: arial; text-align: left;"> </span></div><div class="separator" style="clear: both; text-align: center;"><font face="arial"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzGBl4TRO76agk7FCsasJzSzMqkzAfvWyDJqtcZmr9gWD1zneJl6LgBzX5qD1q9OAhSCUkDo1j6PqVGrOqc_RW8yzBfz_gTGTADn9_ANwzDN3UKThGhWS1VPNkwtk6RvqXBN8H4c0H0k0/s998/dates+loaded+as+text.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="540" data-original-width="998" height="216" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzGBl4TRO76agk7FCsasJzSzMqkzAfvWyDJqtcZmr9gWD1zneJl6LgBzX5qD1q9OAhSCUkDo1j6PqVGrOqc_RW8yzBfz_gTGTADn9_ANwzDN3UKThGhWS1VPNkwtk6RvqXBN8H4c0H0k0/w400-h216/dates+loaded+as+text.PNG" width="400" /></a></font></div><div class="separator" style="clear: both; text-align: center;"><font face="arial"><br /></font></div><p></p><p class="MsoNormal"><font face="arial">The first solution is to convert the data in the frame<o:p></o:p></font></p><p class="MsoNormal"><font face="arial">Select the ABC icon and select Date for Discrete values and Date & Time for continuous values<o:p></o:p></font></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXcl5J3h0yOUkeb7KeeQJWMIZ1h-f3153hVdxf9KVsBluVM-Pk5RsrdPdmzLWzgRVGH1m-xoL65kSndb7xeFn3S8_lT20KaiknlQyLpwQ1spfm14SLex1JMx4vO0ra3Oi2D8rodz2PdOE/s576/date+time+conversion.PNG" style="clear: left; float: left; margin-bottom: 1em; margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="409" data-original-width="576" height="284" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXcl5J3h0yOUkeb7KeeQJWMIZ1h-f3153hVdxf9KVsBluVM-Pk5RsrdPdmzLWzgRVGH1m-xoL65kSndb7xeFn3S8_lT20KaiknlQyLpwQ1spfm14SLex1JMx4vO0ra3Oi2D8rodz2PdOE/w400-h284/date+time+conversion.PNG" width="400" /></a><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial"><br /></font></p><p class="MsoNormal"><font face="arial"><br /></font></p><p class="MsoNormal"><font face="arial"><br /></font></p><p class="MsoNormal"><font face="arial"><br /></font></p><p class="MsoNormal"><font face="arial"><br /></font></p><p class="MsoNormal"><font face="arial"><br /></font></p><p class="MsoNormal"><font face="arial"><br /></font></p><p class="MsoNormal"><font face="arial"><br /></font></p><p class="MsoNormal"><font face="arial"><br /></font></p><p class="MsoNormal"><font face="arial">What if the date is spread over several individual fields like Month, - January, Quarter – Q3, Period – 2019Q2 and a year that may be a number or a String. Those cases will require a calculation before converting to a real date.<o:p></o:p></font></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial">Month – year data entered as a String and Number<o:p></o:p></font></p><p class="MsoNormal"><font face="arial"><br /></font></p><div class="separator" style="clear: both; text-align: center;"><font face="arial"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRRF2XoYQ6NXTSYCoJuP4usZ1aNjCopgOQSsfM8iQ2VsT030Og6ggWx5dsBW2e_WNDXzQiMgtHlwXDsr5EKouAbghkwFPwKsM2SwEnmWNFBYWKyCx2rd2g8ifyDZTHNlQnPUEf0eIANko/s289/month+year+input.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="259" data-original-width="289" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRRF2XoYQ6NXTSYCoJuP4usZ1aNjCopgOQSsfM8iQ2VsT030Og6ggWx5dsBW2e_WNDXzQiMgtHlwXDsr5EKouAbghkwFPwKsM2SwEnmWNFBYWKyCx2rd2g8ifyDZTHNlQnPUEf0eIANko/" /></a></font></div><font face="arial"><o:p></o:p></font><p></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial">Can be converted to the first of the month with a Function – Date()<o:p></o:p></font></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial"><br /></font></p><div class="separator" style="clear: both; text-align: center;"><font face="arial"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizX5uiT-Aic1uVfqc3aLF8wn416XtClcLWZc1jq1LVfQTL6sW0aX3aLLh8xndGuidJJ3a35LEOz1dHs_iOkEr13VQX8fcFLnrRS04Gq2oAJ2yXLmC9J1A4Dx7WNvqTY3dGdO3Mx5ccUMw/s511/date+convert+month+and+year.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="133" data-original-width="511" height="166" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizX5uiT-Aic1uVfqc3aLF8wn416XtClcLWZc1jq1LVfQTL6sW0aX3aLLh8xndGuidJJ3a35LEOz1dHs_iOkEr13VQX8fcFLnrRS04Gq2oAJ2yXLmC9J1A4Dx7WNvqTY3dGdO3Mx5ccUMw/w640-h166/date+convert+month+and+year.PNG" width="640" /></a></font></div><font face="arial"><o:p></o:p></font><p></p><p class="MsoNormal"><font face="arial">And it returns this<o:p></o:p></font></p><p class="MsoNormal"><font face="arial"><br /></font></p><div class="separator" style="clear: both; text-align: center;"><font face="arial"><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmSKuetcV_r02VISkq-F-RWGBsd7bTpvo04J8pr9OXgCIkz7hmWrhSiP0pfsYm44ahbPoztinSlScAJLolz5CY0SyJzcqvWTjxdisNq1DrZ1wfurdgE9cnRLDBIq7vBC7n53xaKXldR18/s579/date+returned+from+Date.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="303" data-original-width="579" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmSKuetcV_r02VISkq-F-RWGBsd7bTpvo04J8pr9OXgCIkz7hmWrhSiP0pfsYm44ahbPoztinSlScAJLolz5CY0SyJzcqvWTjxdisNq1DrZ1wfurdgE9cnRLDBIq7vBC7n53xaKXldR18/w400-h209/date+returned+from+Date.PNG" width="400" /></a></div></font></div><font face="arial"><o:p></o:p></font><p></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial">Occasionally periods are entered in a string – Dateparse is a function that can be used to convert data like this:<o:p></o:p></font></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial"><br /></font></p><div class="separator" style="clear: both; text-align: center;"><font face="arial"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkuU4srqPQ_bxPV1QMlqG9APaK-slwtHjX5LlsrPy2FSd5y_YDM0ko58xq658NHMX-zRskt10KId3yInvGY5cJU20hqCTdDIeTQLHSSLE-PRH_WTAWdk6oMp32nNZO9ZuXreopPEOhja0/s327/period+string+date.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="327" data-original-width="179" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkuU4srqPQ_bxPV1QMlqG9APaK-slwtHjX5LlsrPy2FSd5y_YDM0ko58xq658NHMX-zRskt10KId3yInvGY5cJU20hqCTdDIeTQLHSSLE-PRH_WTAWdk6oMp32nNZO9ZuXreopPEOhja0/s320/period+string+date.PNG" /></a></font></div><font face="arial"><o:p></o:p></font><p></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial">The expression may look complex but if you look at it in pieces -<o:p></o:p></font></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial"><br /></font></p><div class="separator" style="clear: both; text-align: center;"><font face="arial"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ0KijUTVL-hXmpjwd2ovsdZzAMJEuB1j7bDDe1_TRzpazaIp0NgSI-G_GLhnUrXfcz_DwW5ANG2IVe6zzJ7nzh8B2-Vc-faD7lXXrHpSQKcURqydF3E3tk5exnxyfaqGF_fIYo9fllDc/s714/case+convert+period.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="363" data-original-width="714" height="326" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ0KijUTVL-hXmpjwd2ovsdZzAMJEuB1j7bDDe1_TRzpazaIp0NgSI-G_GLhnUrXfcz_DwW5ANG2IVe6zzJ7nzh8B2-Vc-faD7lXXrHpSQKcURqydF3E3tk5exnxyfaqGF_fIYo9fllDc/w640-h326/case+convert+period.PNG" width="640" /></a></font></div><font face="arial"><o:p></o:p></font><p></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial">The string in quotation just tells Tableau how the year – Month – and Date fields will be entered.<o:p></o:p></font></p><p class="MsoNormal"><font face="arial">The Year is the first 4 characters of the Period field, the right 2 characters are the quarter designation – a Case statement will convert them and the firs lot the month “01” is used for the day.<o:p></o:p></font></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial"><br /></font></p><div class="separator" style="clear: both; text-align: center;"><font face="arial"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqawnmJP6qC18hTaxeAIuJHyhrmz7MDn7hWOXT11QPWLMipPqg_MBpBhXgsZBpmt0JCI2px-a3F8i9WFn43R26gzQ1_PPCoYnDSDcd3pwjxB8AYutuK_e0bLRSeFhuI60NsWra1vx1hiA/s230/converted+4+periods.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="175" data-original-width="230" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqawnmJP6qC18hTaxeAIuJHyhrmz7MDn7hWOXT11QPWLMipPqg_MBpBhXgsZBpmt0JCI2px-a3F8i9WFn43R26gzQ1_PPCoYnDSDcd3pwjxB8AYutuK_e0bLRSeFhuI60NsWra1vx1hiA/" /></a></font></div><font face="arial"><o:p></o:p></font><p></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial">One final example – converting timestamp dates to a duration – Some users have data that includes a start and end timestamp and need to determine the duration of an event – In days, hours, minutes and seconds<o:p></o:p></font></p><p class="MsoNormal"><font face="arial">The data may look like this<o:p></o:p></font></p><p class="MsoNormal"><font face="arial"><br /></font></p><div class="separator" style="clear: both; text-align: center;"><font face="arial"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFYMgFLj73D3Swm9t0gE-cJ2pIj8HLE6rTFLUic6p3KgPzFcEWV8IYj3P7bW8OgY30e-Y-rVGjJuSACWsJlfBZnN7tRUPpcIvC2TYcjqMD7ItvQI28vu6IwLX2RWKxram90ewDsAZCkPk/s289/month+year+input.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="259" data-original-width="289" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFYMgFLj73D3Swm9t0gE-cJ2pIj8HLE6rTFLUic6p3KgPzFcEWV8IYj3P7bW8OgY30e-Y-rVGjJuSACWsJlfBZnN7tRUPpcIvC2TYcjqMD7ItvQI28vu6IwLX2RWKxram90ewDsAZCkPk/" /></a></font></div><font face="arial"><o:p></o:p></font><p></p><p class="MsoNormal"><font face="arial">One solution is to determine the duration at the lowest level – seconds and then convert the results into Days, Hours, Minutes, Seconds in separate calculations<o:p></o:p></font></p><p class="MsoNormal"><font face="arial">Datediff will return the duration in seconds based on the start and end timestamps<o:p></o:p></font></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial"><br /></font></p><div class="separator" style="clear: both; text-align: center;"><font face="arial"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy_2z94PYFloaUiOHic3uAZb0O7gLBqAPpIJJt_P3j9sX6e4L_VM2aPVay_0pEd9YHy9yfQMwbO2Y7PV-kx4-JfU4MpBLCfiPSxC6q9STGqPg-QdqKVbcKV7PBmuwQzmPM39Je4Zug6vM/s748/date+diff+sec.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="99" data-original-width="748" height="84" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy_2z94PYFloaUiOHic3uAZb0O7gLBqAPpIJJt_P3j9sX6e4L_VM2aPVay_0pEd9YHy9yfQMwbO2Y7PV-kx4-JfU4MpBLCfiPSxC6q9STGqPg-QdqKVbcKV7PBmuwQzmPM39Je4Zug6vM/w640-h84/date+diff+sec.PNG" width="640" /></a></font></div><font face="arial"><o:p></o:p></font><p></p><p class="MsoNormal"><font face="arial">Then number of days is simply the integer part of the total duration in seconds at divided by the number of seconds in a day – for example<o:p></o:p></font></p><p class="MsoNormal"><font face="arial">Days = Int([datediff at the second level]/(24*60*60))<o:p></o:p></font></p><p class="MsoNormal"><font face="arial">For the remaining dateparts, make use of the Modulo function – Modulo returns the remainder of a division – e.g. modulo will return 3 for 7/4 – So when dividing the total seconds by the number of seconds in a day modulo will return the number of seconds left over – dividing that number by the number of seconds in an hour (3600) and taking the integer value will return the number of hours <o:p></o:p></font></p><p class="MsoNormal"><font face="arial">Hours = INT(([datediff at the second level]%(24*(60)*60))/(60*60))<o:p></o:p></font></p><p class="MsoNormal"><font face="arial">And<o:p></o:p></font></p><p class="MsoNormal"><font face="arial">Minutes = INT(([datediff at the second level]%((60)*60))/(60))<o:p></o:p></font></p><p class="MsoNormal"><font face="arial">And Seconds = INT(([datediff at the second level]%(60)))<o:p></o:p></font></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial">Finally – concatenating the parts together and adding the result to the tooltip<o:p></o:p></font></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial"><br /></font></p><div class="separator" style="clear: both; text-align: center;"><font face="arial"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFX8JnzBaeUbAJy6e0Xv8VVAKWK3z16AZS6FfiBAKV-dVkfGCuIrtd-8SWn50vVTtvBhIFoUN8tNIzUkOLzUNInYb4jgAMBMlTyLy94J12OlVI8_d6m9leLSfZltmQGqAQZFBlshrCSAw/s921/text+duration.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="145" data-original-width="921" height="100" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFX8JnzBaeUbAJy6e0Xv8VVAKWK3z16AZS6FfiBAKV-dVkfGCuIrtd-8SWn50vVTtvBhIFoUN8tNIzUkOLzUNInYb4jgAMBMlTyLy94J12OlVI8_d6m9leLSfZltmQGqAQZFBlshrCSAw/w640-h100/text+duration.PNG" width="640" /></a></font></div><font face="arial"><o:p></o:p></font><p></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial"><br /></font></p><div class="separator" style="clear: both; text-align: center;"><font face="arial"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBoVZpcHuzlcUwBzb6ZmczaScq_inJos1V0gdl3f6jZLHB1eb_oQ25obkuMERlkiWLlsuTArSXHUoNh2XOmd2Pbk1QAduNOa1w7WbOlHOR1bFAps4M9hM1L2xRcn4AYnUk1unVDbU3U5U/s1287/duration+in+toolltip.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="728" data-original-width="1287" height="226" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBoVZpcHuzlcUwBzb6ZmczaScq_inJos1V0gdl3f6jZLHB1eb_oQ25obkuMERlkiWLlsuTArSXHUoNh2XOmd2Pbk1QAduNOa1w7WbOlHOR1bFAps4M9hM1L2xRcn4AYnUk1unVDbU3U5U/w400-h226/duration+in+toolltip.PNG" width="400" /></a></font></div><font face="arial"><o:p></o:p></font><p></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p><p class="MsoNormal"><font face="arial">Hope this helps the next time you are faced with a Date field that was entered as text. Now practice on some data of your own<o:p></o:p></font></p><p class="MsoNormal"><o:p><font face="arial"> </font></o:p></p>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-60505662534866896142020-05-12T15:03:00.004-05:002022-01-24T08:53:58.516-06:00FAQ Series - Weighted Averages<div><span face="arial, helvetica, sans-serif"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p></span></div><div><span face="arial, helvetica, sans-serif"><br /></span></div><div><span face="arial, helvetica, sans-serif">Lately there have been a lot of Forum questions about calculating weighted averages </span></div><div><span face="arial, helvetica, sans-serif"><br /></span></div><div><span face="arial, helvetica, sans-serif"><font face="arial, helvetica, sans-serif" style="font-family: arial, helvetica, sans-serif;">Mathematically, weighted average is defined as the sum of the individuals weights x the values divided by the total of the weights </font><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYmVAM4p9ivmyoHACcUq37Qgn-OwKKVvTwbeOtuBTsyuTy5rzrboWdAkCUZRwnXcRN2r5aUAtHY_kCCHz-Ayx_3qfNUIi-IZ5NRy1r0J5-1JdUR8AZOwNjS8q75bxgmAITw37mqpISjmU/s1600/wa+nath+formula.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="213" data-original-width="333" height="204" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYmVAM4p9ivmyoHACcUq37Qgn-OwKKVvTwbeOtuBTsyuTy5rzrboWdAkCUZRwnXcRN2r5aUAtHY_kCCHz-Ayx_3qfNUIi-IZ5NRy1r0J5-1JdUR8AZOwNjS8q75bxgmAITw37mqpISjmU/s320/wa+nath+formula.PNG" width="320" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><b>1 Table Calculation Example </b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><b><br /></b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">Posters are familiar with how to find weighted averages with a spreadsheet calculator </div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhB8a-wJy3N5roKtCiSKEGf-KVePSpxKrQykZV0aTaNkq79BKTsZuNkK8w7SKeN_wu5__Gyo7juhyDhB2655GJONfYgShaqY1YC_5N_KTTFLUBPWXRI8WVb60Nw6sycrUps8SG4yknXfTg/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="181" data-original-width="490" height="148" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhB8a-wJy3N5roKtCiSKEGf-KVePSpxKrQykZV0aTaNkq79BKTsZuNkK8w7SKeN_wu5__Gyo7juhyDhB2655GJONfYgShaqY1YC_5N_KTTFLUBPWXRI8WVb60Nw6sycrUps8SG4yknXfTg/w400-h148/excel+wdt+avg+example.PNG" width="400" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">But now with how it would be donw in Tableau - </div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">Start with a table calculation to get the percent of total weight :</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><font face="arial"><font face="arial, helvetica, sans-serif"><b> Weight Percent of total = </b></font><span style="font-family: "times new roman"; text-align: left;"><font face="arial, helvetica, sans-serif"><b>SUM([Weight]) / TOTAL(SUM([Weight]))</b></font></span></font></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">then the row level weighted averages are:</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><font face="arial, helvetica, sans-serif"><b> Weighted Average = [Weight percent of total]*sum([Value])</b></font></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><font face="arial, helvetica, sans-serif"><b><br /></b></font></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><font face="arial, helvetica, sans-serif"><b><br /></b></font></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAR7qPYixSa35aHW4nCq6nk88GjPWafCuVRCM5UwiFi7tGNHbtquP7J6aub4EIB63IVgtC-HqbbCPnyioJVpvB5GiF3CFihPmvFGOMiIZwGYUdHcdeK5RnyYQ1nxK0wtAwkkvsNKHK3bc/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="499" data-original-width="1043" height="306" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAR7qPYixSa35aHW4nCq6nk88GjPWafCuVRCM5UwiFi7tGNHbtquP7J6aub4EIB63IVgtC-HqbbCPnyioJVpvB5GiF3CFihPmvFGOMiIZwGYUdHcdeK5RnyYQ1nxK0wtAwkkvsNKHK3bc/w640-h306/simple+example+tab+-+row+level.PNG" width="640" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><font face="arial">At the row level the calculations are the same as the spreadsheet calculation </font></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><font face="arial">If we add Grand Total - the totals are not correct? </font></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrTEOhEcygmTk2LarffHLcoN5Uuf982FpXM2tcF3kKq3z8wBZtw4nydUYIzMsUTSXi9gf2Phdavi0HTrbmFwaFwuq1ELcPFY3Un6nyusG0tJ9UGgceRL2EpnnyvjUr-CtGqFVHnq9LJT0/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="508" data-original-width="1001" height="325" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrTEOhEcygmTk2LarffHLcoN5Uuf982FpXM2tcF3kKq3z8wBZtw4nydUYIzMsUTSXi9gf2Phdavi0HTrbmFwaFwuq1ELcPFY3Un6nyusG0tJ9UGgceRL2EpnnyvjUr-CtGqFVHnq9LJT0/w640-h325/simple+example+with+total.PNG" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; text-align: left;"><font face="arial">The solution is to include a formula that forces a value into the Grand Total line and the Wtd Avg in all other rows </font></div><div class="separator" style="clear: both; text-align: left;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; text-align: left;"><font face="arial">Size() = 1 in the Grand Total and Sub Total rows or columns</font></div><div class="separator" style="clear: both; text-align: center;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; text-align: center;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both;"><font face="arial"><b>If SIZE()=1 then </b></font></div><div class="separator" style="clear: both;"><font face="arial"><b><br /></b></font></div><div class="separator" style="clear: both;"><font face="arial"><b>window_sum(sum([Value]*[Weight]))/window_sum(sum([Weight]))</b></font></div><div class="separator" style="clear: both;"><font face="arial"><b><br /></b></font></div><div class="separator" style="clear: both;"><font face="arial"><b>else [Wtd Avg] end</b></font></div></div></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">and the result return the expected values:</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitxZAU4W8Ge2v_tfF2M2ORBJMHQ7AGWWICgG3_IHUBfKJmrXKE3rIU2a_2UoeNdGl-ZQVlsGUi06qG91SWRY_mUS2YeqxZ60J4B9Zk6Ujo5SoS6KUy4JbayHb9t9CtlWB-gwT3u5B0r0A/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="514" data-original-width="1093" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitxZAU4W8Ge2v_tfF2M2ORBJMHQ7AGWWICgG3_IHUBfKJmrXKE3rIU2a_2UoeNdGl-ZQVlsGUi06qG91SWRY_mUS2YeqxZ60J4B9Zk6Ujo5SoS6KUy4JbayHb9t9CtlWB-gwT3u5B0r0A/w640-h300/simple+example+with+correct+total.PNG" width="640" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">The solution also works when another dimension is added </div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-bvayDoYgnBmuN-E1RxIDHBm4P9ODoggLnQef-9bqYf8W_4SxvKW-A8XLE6elsfxdPpax-B9TpurOL1xr8Tj5DSLUXXEY7_csC0C5vwn7zmBR_tVHYbfofEHziIavo2HBWWGD-Gn__uk/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="571" data-original-width="965" height="378" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-bvayDoYgnBmuN-E1RxIDHBm4P9ODoggLnQef-9bqYf8W_4SxvKW-A8XLE6elsfxdPpax-B9TpurOL1xr8Tj5DSLUXXEY7_csC0C5vwn7zmBR_tVHYbfofEHziIavo2HBWWGD-Gn__uk/w640-h378/multi+dim+simple+example.PNG" width="640" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">set the table calculations to Pane Down </div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrPzyy9oNW6ucKxghDk0xg6Uvls_Q54yTHVSoJ_ySlwcXwpIuxpQ_wZRdHiiTxfVBwWsTXtZ3HdwrYToOpZ0NcakfxCbpUvj7eWYxEtEGGBdMCXtiYvD8Fduy2aRxiyHAAPLmoMaQAc-c/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="513" data-original-width="322" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrPzyy9oNW6ucKxghDk0xg6Uvls_Q54yTHVSoJ_ySlwcXwpIuxpQ_wZRdHiiTxfVBwWsTXtZ3HdwrYToOpZ0NcakfxCbpUvj7eWYxEtEGGBdMCXtiYvD8Fduy2aRxiyHAAPLmoMaQAc-c/w251-h400/set+up+for+table+calc.PNG" width="251" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">Table calculations are last in the Order of Operations so when possible I use LOD's - I also think the LOD approach is easier to understand - see the next 3 examples </div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><b>2 - Toy Store Example</b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><b><br /></b></div><div style="font-family: "times new roman";"><span face="arial, helvetica, sans-serif">Start with a toy store data set - 3 categories with 4 products in each - and determine the weighted average sales by category and overall</span></div><div style="font-family: "times new roman";"><span face="arial, helvetica, sans-serif"><br /></span></div><div class="separator" style="clear: both; font-family: "times new roman"; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW2v24eSRKv6R517VorCwwlHKtD28afYhILGlTSFBQV9KgerZFsLN6hQkwTPeOH7ckP2AZgVBlnjwneStmXSHROS9SEREEBBToFZ1Z3rzw3nAjlM8jwOhv5U0VamjXjMTjRCG7T3oSj10/s1600/toy+sales+input.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="349" data-original-width="428" height="325" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW2v24eSRKv6R517VorCwwlHKtD28afYhILGlTSFBQV9KgerZFsLN6hQkwTPeOH7ckP2AZgVBlnjwneStmXSHROS9SEREEBBToFZ1Z3rzw3nAjlM8jwOhv5U0VamjXjMTjRCG7T3oSj10/s400/toy+sales+input.PNG" width="400" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">The weights are the number of units sold and the values are the dollars - </div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">The numerator can be calculated with an LOD:</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><b><br /></b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><b>{ FIXED [Category],[Item]: sum([Units])*sum([Dollars]) }</b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">The denominator is </div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><span style="text-align: left;"><br /></span></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><span style="text-align: left;">:</span><b>({ FIXED [Category],[Item]: sum([Units])})</b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">the weighted average is:</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><b>sum([LOD Numerator])/sum([LOD Denominator])</b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">by using LODs the viz can be displayed in detail (including the total and subtotals)</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgColNKy_kvTTfKfz7tsj4rYlFFmqf-TXgC3Wfhfqq3wIlonJJbcrqqtkM1sD_Z0ypqlSLqOEjQHb2d0RHvNbtMRcQeBehgohWE0XwzQzHKD4SUYngjwpG2Xw5B4ucMVcjaG3s9SWO3l8c/s1600/toy+store+WA+detail.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="478" data-original-width="807" height="378" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgColNKy_kvTTfKfz7tsj4rYlFFmqf-TXgC3Wfhfqq3wIlonJJbcrqqtkM1sD_Z0ypqlSLqOEjQHb2d0RHvNbtMRcQeBehgohWE0XwzQzHKD4SUYngjwpG2Xw5B4ucMVcjaG3s9SWO3l8c/s640/toy+store+WA+detail.PNG" width="640" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">Or the hierarchy can be compressed to show the summary</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXK6Id5sRZHVrYLzRfHKNVj5GTduOlJy-g4KWa24A1AEJf5_e5Hd6nJ9RvU2I542bfAThYe5lUg_OzJzOAG3pRWB5fWG7MW9bFgX_AUd4w_T6c6ALuhMqyh6RwqYFdcGYy2aAXJDGeOSY/s1600/toy+store+summary.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="507" data-original-width="785" height="412" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXK6Id5sRZHVrYLzRfHKNVj5GTduOlJy-g4KWa24A1AEJf5_e5Hd6nJ9RvU2I542bfAThYe5lUg_OzJzOAG3pRWB5fWG7MW9bFgX_AUd4w_T6c6ALuhMqyh6RwqYFdcGYy2aAXJDGeOSY/s640/toy+store+summary.PNG" width="640" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><b>3 Crime Rate Example</b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><b><br /></b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">This example uses crime data broken out by region, state, and city to find the crime rate per 1000 population at the state and region level</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">The data is organized like this</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiB_Ir6kbkRtUwT52wV4YHOkPpKijK5lXukfUCC5e6tlsfZ3Ctb69TJixyx5arLKIuSZ-7vyAv26iQ10Gl0zjmKVhIgpeLoc3GSz_khLaNs4zEiGUbbgq77iLCaqlzxSNZ6DKBTJMqo5Zs/s1600/cime+data+set.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="547" data-original-width="827" height="422" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiB_Ir6kbkRtUwT52wV4YHOkPpKijK5lXukfUCC5e6tlsfZ3Ctb69TJixyx5arLKIuSZ-7vyAv26iQ10Gl0zjmKVhIgpeLoc3GSz_khLaNs4zEiGUbbgq77iLCaqlzxSNZ6DKBTJMqo5Zs/s640/cime+data+set.PNG" width="640" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">The crime rate per 1000 at the city level can be expressed using Include LOD's - the Include statement at the city level will automatically accumulate the hierarchy is collapsed </div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">- Note also the numerator and the denominator are determined separately</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><span style="text-align: left;"><font face="arial, helvetica, sans-serif"><b>Total crime = </b></font></span><b style="font-family: arial, helvetica, sans-serif;">sum({ INCLUDE [City]:sum([Nonviolent])+sum([Violent crime])})</b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><b style="font-family: arial, helvetica, sans-serif;"><br /></b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><span style="text-align: left;"><font face="arial, helvetica, sans-serif"><b>Pop In Thousands = </b></font></span><b style="font-family: arial, helvetica, sans-serif;">sum({ INCLUDE [City]: Round(sum([Population])/1000,1) })</b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><b style="font-family: arial, helvetica, sans-serif;"><br /></b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><b style="font-family: arial, helvetica, sans-serif;">And </b><span style="text-align: left;"><font face="arial, helvetica, sans-serif"><b>State Level Wt Avg = </b></font></span></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><b style="font-family: arial, helvetica, sans-serif; text-align: left;">{ FIXED [State]:sum([Total crime])/sum([Pop In Thousands])}</b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><b style="font-family: arial, helvetica, sans-serif; text-align: left;"><br /></b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><b style="font-family: arial, helvetica, sans-serif; text-align: left;">And at the City level </b><span style="text-align: left;"><font face="arial, helvetica, sans-serif"><b>sum([Total crime])/sum([Pop In Thousands])</b></font></span></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><span style="text-align: left;"><font face="arial, helvetica, sans-serif"><b><br /></b></font></span></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">Display the results in map form using a viz in tooltip to display the crime rate at the city level as bars and the state level weighted average as reference lines </div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi85YMIT1AScxyLQBfrf3b4PnmYPcpxwCQ5lo49dca-68Lkkg8pMjY29gh_e9N35paX3-M2lo9GQ0eKB1LjML4CGUW4ukQidYYMkdfyO2-FMk9ngvQL1KtKKUsoAYWBbQQSPtDRLr3V_Mc/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="754" data-original-width="1629" height="296" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi85YMIT1AScxyLQBfrf3b4PnmYPcpxwCQ5lo49dca-68Lkkg8pMjY29gh_e9N35paX3-M2lo9GQ0eKB1LjML4CGUW4ukQidYYMkdfyO2-FMk9ngvQL1KtKKUsoAYWBbQQSPtDRLr3V_Mc/w640-h296/crime+rate+map.PNG" width="640" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">Create a bar chart at the state/city level for city level crime rate and include a reference line for the state weighted average crime rate</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSu1_xzrdh7oGj7NaA-ELwP2GfyovlOShxSm38CeLw7vNjBFOGG_2HaXc7qEaamM82-JQDAeFlydv3YdYi1EKVFvrUSmRnPTnifHhfNMW22nEjM1F8vLw106DANeLGhfMdaQBtTwdJ8Bg/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="907" data-original-width="1621" height="358" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSu1_xzrdh7oGj7NaA-ELwP2GfyovlOShxSm38CeLw7vNjBFOGG_2HaXc7qEaamM82-JQDAeFlydv3YdYi1EKVFvrUSmRnPTnifHhfNMW22nEjM1F8vLw106DANeLGhfMdaQBtTwdJ8Bg/w640-h358/Detail+state+level+wt+avg.PNG" width="640" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">and add a reference line to the columns</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2Ew9zZa2OmOP8NfbamJMcHjaQoE0NlwzF0MJzYkDoB_ZGsN_fZp8EiYD7vAyfEZyFgHWomsn8R80gsCQF3MyWeFIpO-jsZxf2E5wPoyjnxklfpJC4ZhRWvU1jpZhTtGnKst46O6zqlIQ/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="548" data-original-width="385" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2Ew9zZa2OmOP8NfbamJMcHjaQoE0NlwzF0MJzYkDoB_ZGsN_fZp8EiYD7vAyfEZyFgHWomsn8R80gsCQF3MyWeFIpO-jsZxf2E5wPoyjnxklfpJC4ZhRWvU1jpZhTtGnKst46O6zqlIQ/w281-h400/state+ref+line+set+up.PNG" width="281" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">Finally on the map - place the detail sheet in the tooltip and filter for State</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgb4kUhE8k5LCrkb8T-BDsK45LIwZrMSY4g5GCcNVxPpb4MsihOQfztm48gLH7xoSFR17Bu6Cfjl43V9V9lLQxjxSFBg0kSVI0bTka77akQ_HKgcxe34IxCf-sgnb1JiiuQs9bOTlhYK9U/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="411" data-original-width="666" height="246" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgb4kUhE8k5LCrkb8T-BDsK45LIwZrMSY4g5GCcNVxPpb4MsihOQfztm48gLH7xoSFR17Bu6Cfjl43V9V9lLQxjxSFBg0kSVI0bTka77akQ_HKgcxe34IxCf-sgnb1JiiuQs9bOTlhYK9U/w400-h246/tooltip+setup.PNG" width="400" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">Hover over a city and the detail chart filtered at the state level opens in the tooltip</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizHXoMCsNiTgHSq1L5lmBxb_6LV4rKPCd5685UmKjSxIT1ovUO_syfaiMDQjdi_vBqcaFzwJN0pu9vTFiwnzsxtOnp5N21r0tdZBZL8tI4-Y7XL2gl3VCCjsgcrNW9rp5xyRjSVrnygLs/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="782" data-original-width="1589" height="314" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizHXoMCsNiTgHSq1L5lmBxb_6LV4rKPCd5685UmKjSxIT1ovUO_syfaiMDQjdi_vBqcaFzwJN0pu9vTFiwnzsxtOnp5N21r0tdZBZL8tI4-Y7XL2gl3VCCjsgcrNW9rp5xyRjSVrnygLs/w640-h314/crime+rate+final+map.PNG" width="640" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><b>4 Weighted Average Interest Rate</b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><b><br /></b></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">A common use case is to determine the weighted average interest across a portfolio of loans</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghg-cFfaBAGAdBFNZ-q7M9BEOy0VmXwPdf38NKMpU-L5zLF8Z2aKppQUSOLWkIVgDmQTSaWC2AEUXbh-ayjHL-GFQ8NSwaV0M3fBKW8rzWAnChPlBuNU34ZgMhrA2Okbb3izzeFepOYV8/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="707" data-original-width="724" height="390" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghg-cFfaBAGAdBFNZ-q7M9BEOy0VmXwPdf38NKMpU-L5zLF8Z2aKppQUSOLWkIVgDmQTSaWC2AEUXbh-ayjHL-GFQ8NSwaV0M3fBKW8rzWAnChPlBuNU34ZgMhrA2Okbb3izzeFepOYV8/w400-h390/loan+data.PNG" width="400" /></a></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div></span></div><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><span face="arial, helvetica, sans-serif"><div class="separator" style="clear: both; text-align: left;"><br /></div></span></blockquote><div><span face="arial, helvetica, sans-serif"><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">Given the face value of the loan an the interest rate the first step is find the interest in dollars for each loan</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><p align="center" class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;"><span face="arial, sans-serif" style="font-size: 12pt;"><b>Interest Dollars = sum([Load Amount]*[Interest Rate])</b><o:p></o:p></span></p></div><div class="separator" style="clear: both; text-align: center;"><span style="text-align: left;"><font face="arial, helvetica, sans-serif"><br /></font></span></div><div class="separator" style="clear: both; text-align: center;"><span style="text-align: left;"><font face="arial, helvetica, sans-serif"><br /></font></span></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">the weighted average interest rate using an Include LOD (using include the rate will roll up as the hierarchy is collapsed</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><font face="arial, helvetica, sans-serif"><b>Weighted ave interest rate = </b></font></div><div class="separator" style="clear: both; text-align: center;"><font face="arial, helvetica, sans-serif"><b><br /></b></font></div><div class="separator" style="clear: both; text-align: center;"><font face="arial, helvetica, sans-serif"><b>[Interest in dollars]/ </b></font></div><div class="separator" style="clear: both; text-align: center;"><font face="arial, helvetica, sans-serif"><b>sum({ INCLUDE [Loan Purpose], [ID number] : sum([Load Amount]) })</b></font></div><div class="separator" style="clear: both; text-align: center;"><font face="arial, helvetica, sans-serif"><br /></font></div><div class="separator" style="clear: both; text-align: center;"><font face="arial, helvetica, sans-serif"><br /></font></div><div class="separator" style="clear: both; text-align: center;"><font face="arial, helvetica, sans-serif"><br /></font></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;">At the detail level the viz is simply</div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsbV6rin-M4sY2veRIL_TAsZ_6qxo7t2DTjW7n1LHHZz4ErcfCeGzCofW5_8oBTD7Nrgm0xB2_CI6F1DyWjWvhY1CElC0rRkNU7coBzQE5QytVb0sQvXjWvwAmqFuWx7jPB1Ux_3SyC34/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="654" data-original-width="987" height="424" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsbV6rin-M4sY2veRIL_TAsZ_6qxo7t2DTjW7n1LHHZz4ErcfCeGzCofW5_8oBTD7Nrgm0xB2_CI6F1DyWjWvhY1CElC0rRkNU7coBzQE5QytVb0sQvXjWvwAmqFuWx7jPB1Ux_3SyC34/w640-h424/detail+interet+on+loan.PNG" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; text-align: left;"><font face="arial">Collapsing the hierarchy to the loan purpose level and adding in the Grand Total returns the the line of business and total portfolio weighted averages </font></div><div class="separator" style="clear: both; text-align: left;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; text-align: left;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; text-align: left;"><font face="arial"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC7Lwvme01Eu53hSw-2OyWg9YfN5dOxBFdq4pELOWN-hMP-iGrBzV0-Pq2os9F5l6yDO-OMeL8s_d2SspGHvRYJA_PyesKOxtVsQfWpHOD4B7TnFsEFkDH4quZDnJz6eGNGUF1RP7LP2A/" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="470" data-original-width="910" height="330" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgC7Lwvme01Eu53hSw-2OyWg9YfN5dOxBFdq4pELOWN-hMP-iGrBzV0-Pq2os9F5l6yDO-OMeL8s_d2SspGHvRYJA_PyesKOxtVsQfWpHOD4B7TnFsEFkDH4quZDnJz6eGNGUF1RP7LP2A/w640-h330/Loan+summaary.PNG" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div> </font></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;"><font face="arial">I hope this help you understand how to calculate weighted averages - the workbooks containing the examples used here can be found at </font></div><div class="separator" style="clear: both; text-align: left;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; text-align: left;"><a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/weightedavg/Weightedaverages">https://public.tableau.com/profile/jim.dehner#!/vizhome/weightedavg/Weightedaverages</a></div><div class="separator" style="clear: both; text-align: left;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; text-align: left;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; text-align: left;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; text-align: left;"><font face="arial">Enjoy</font></div><div class="separator" style="clear: both; text-align: left;"><font face="arial">Jim</font></div><div class="separator" style="clear: both; text-align: left;"><font face="arial"><br /></font></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: center;"><br /></div><div class="separator" style="clear: both; font-family: arial, helvetica, sans-serif; text-align: left;"><br /></div></span></div>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-51033583939407811372020-04-12T12:16:00.000-05:002020-04-12T12:16:40.735-05:00FAQ Series - Creating Groups <span style="font-family: "arial" , "helvetica" , sans-serif;">Groups are a way to collect like items without creating an aggregate - They can be static or dynamic, created manually, through a join or as the result of a calculation and spreadsheet users will find them as a useful replacement for a VLOOKUP -</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlkMsnysObmo3WU5BgrsSswRUNHcvBnnXv6VG1-BqFzJLpap7K2HZYkb1tJmn5nMwmSva-9N3IT5WQwXsXFCLpfvm3wGzTziLXG4pMDTn7VH7iSHVsnwfxwWaoUz6-IPjYoBqByCJu-10/s1600/banner+for+public+post.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="872" data-original-width="1547" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlkMsnysObmo3WU5BgrsSswRUNHcvBnnXv6VG1-BqFzJLpap7K2HZYkb1tJmn5nMwmSva-9N3IT5WQwXsXFCLpfvm3wGzTziLXG4pMDTn7VH7iSHVsnwfxwWaoUz6-IPjYoBqByCJu-10/s400/banner+for+public+post.PNG" width="400" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Manual Grouping</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Static groups can easily be created using the Create Groups functionality from the Dimension pane. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Open the dimension and select "Create Group"</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_vjQRSuMzDCF8ZBe0Gs9jlLJBXuR8p02DmjWy4wVqJB_AwsUT_GK8gYZOVpt01ulBMY-mDGqNinWaMamQ9EPpI_3nx3LGWc7mLv6yPEC1MDfUmr764NUQqX2QeHQlJgrB3LmbmmrRI9w/s1600/Image+001.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_vjQRSuMzDCF8ZBe0Gs9jlLJBXuR8p02DmjWy4wVqJB_AwsUT_GK8gYZOVpt01ulBMY-mDGqNinWaMamQ9EPpI_3nx3LGWc7mLv6yPEC1MDfUmr764NUQqX2QeHQlJgrB3LmbmmrRI9w/s640/Image+001.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">A window will open with several options on how to group members of the dimension</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Search Option </b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">The search option can be used to select values with a common value or string - Use "Find All" then select "Group"</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwUeYY_6nRoK8bqL6CexeRPE7CHyUuK2IqLmWPFItg7o4DDyVBnIn6SVb_i1NK1_o2vNHKV0qAcL3niJmkbcnpS5PyAiWQMlZQ4E34KYkNoAXQL8cTkqlUZ5qlKfCicnCEvP5cRcAKvQk/s1600/Image+002.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwUeYY_6nRoK8bqL6CexeRPE7CHyUuK2IqLmWPFItg7o4DDyVBnIn6SVb_i1NK1_o2vNHKV0qAcL3niJmkbcnpS5PyAiWQMlZQ4E34KYkNoAXQL8cTkqlUZ5qlKfCicnCEvP5cRcAKvQk/s640/Image+002.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Then Rename the group for use later</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyNnGN5_pDORr2sO96zmSWW-Ozi1ERTiCK5kLO3PhqUWSkMeBuJUlAKS093NGkofBAlHCywEtmoKgR0wR1a10kgWNgv4AEHe4sun2bFTVuRC8klU0koZHHLdz8OwyDn1TFJuKcZM95OpM/s1600/Image+004.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyNnGN5_pDORr2sO96zmSWW-Ozi1ERTiCK5kLO3PhqUWSkMeBuJUlAKS093NGkofBAlHCywEtmoKgR0wR1a10kgWNgv4AEHe4sun2bFTVuRC8klU0koZHHLdz8OwyDn1TFJuKcZM95OpM/s640/Image+004.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Highlight and Select Option</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Using the mouse, shift or ctrl keys highlight the members to be included then select Group</span><br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhS_zayFL3rKb9VtTEEHXL_Kvl396eQK2hh9zIwIT5f9ZCAP7Ltd-KiUhlrRxRQlqbFIPD2Auv3b8BXyL9w4YVwoEgkVC4jExlVmCYeOxVs5cHGrULZuM3A98Op1r6OH26jjXu0yqkNotE/s1600/Image+005.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhS_zayFL3rKb9VtTEEHXL_Kvl396eQK2hh9zIwIT5f9ZCAP7Ltd-KiUhlrRxRQlqbFIPD2Auv3b8BXyL9w4YVwoEgkVC4jExlVmCYeOxVs5cHGrULZuM3A98Op1r6OH26jjXu0yqkNotE/s640/Image+005.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Add to existing group</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">When new members are to be added to an existing group use the highlight option and then "Add To" in the upper right corner and select the correct group from the dropdown</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9VGzUYd3pIlW4vBr6FjpO8sf4douP03HpEazKtNIwr3JL5Y1WWZu9aHkGl5fsyj_LV8pdDZvwDqE9Aw5mxXoF4BJKOnDxEYUv4NCShdSWtxk7VEc4b4BfFqezgQ08nlUgblCquu9hECw/s1600/Image+006.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9VGzUYd3pIlW4vBr6FjpO8sf4douP03HpEazKtNIwr3JL5Y1WWZu9aHkGl5fsyj_LV8pdDZvwDqE9Aw5mxXoF4BJKOnDxEYUv4NCShdSWtxk7VEc4b4BfFqezgQ08nlUgblCquu9hECw/s640/Image+006.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Create and Other Group</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Any remaining members can be collected in an "Other" group using the check off box on the lower left</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2DP9oUHzuZ_dxlJDgOWYUAGcxzbM0ImhuPVacnOL2gTgd9FtSx9wDWtPmlKc-3ZIuMsGe3UbrEjYaSiJOuVSfd29Ip434eD67pazquKHbrHd66MYWiMMi0FE9zehZ23CBVsJY6XB516Q/s1600/Image+007.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2DP9oUHzuZ_dxlJDgOWYUAGcxzbM0ImhuPVacnOL2gTgd9FtSx9wDWtPmlKc-3ZIuMsGe3UbrEjYaSiJOuVSfd29Ip434eD67pazquKHbrHd66MYWiMMi0FE9zehZ23CBVsJY6XB516Q/s640/Image+007.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">When done there will be a Dimension(group) will be added to the dimension pane which can be used alone or as part of a hierarchy</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKY83AgJmF9ARMMbkMhK1wZwYfbqqpCc0dxfiKtkWNY8UZpRtdMlDPz24Ro4OahuTDb62C_SsL2ybuDE7l94nQnoTpIUsh0FNmUGxDkmGTEK8pnp7Usv-y7oIV30DRiJfnzpFV26ILie0/s1600/Image+008.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKY83AgJmF9ARMMbkMhK1wZwYfbqqpCc0dxfiKtkWNY8UZpRtdMlDPz24Ro4OahuTDb62C_SsL2ybuDE7l94nQnoTpIUsh0FNmUGxDkmGTEK8pnp7Usv-y7oIV30DRiJfnzpFV26ILie0/s640/Image+008.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Create Group is easy to use for static (unchanging groups). If the members of the groups are even infrequently changed other options may be a better choice</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Use a Join to Create Groups</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Often posters on the Forum want to recreate a Vlookup function from a spreadsheet calculator. The approach uses a separate file that lists the dimension value and the corresponding group </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">For example: Group customers alphabetically by the first letter of their last name. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">I created a simple excel file with the customer name (first and last) to match same dimension in our Tableau Superstore example, broke out the first and last name and then the first letter of the last name.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJhyphenhyphen4lVP-QD2FMCiuV5RFX6uWaH99CKrQTieSIkVq7NC12xK9EtY1uDVmDFwObNdU89q_wG2xTKyeP3m7ElNzrN-JHscsLqaV9qLguOBIhGLTNY7P7EjQnAo3qdKxwQYmxtym9q1hUrOQ/s1600/excel+sheet+to+join.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="518" data-original-width="659" height="313" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJhyphenhyphen4lVP-QD2FMCiuV5RFX6uWaH99CKrQTieSIkVq7NC12xK9EtY1uDVmDFwObNdU89q_wG2xTKyeP3m7ElNzrN-JHscsLqaV9qLguOBIhGLTNY7P7EjQnAo3qdKxwQYmxtym9q1hUrOQ/s400/excel+sheet+to+join.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Then join to the Superstore data on Customer Name</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XGj4djMXS5cbQbcxQmOOHk3Vf84AyzZ51AOjMF4l-p4u4dyJqRbyzSgJFhIoVnXqzjmiYFfeySaeQl8XdhOrNa_gb_jjRtdEw9HqTIosevNWNaYr1cdPTX-EC_t-Iv2Fc2pqVcRpPCI/s1600/Image+009.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1XGj4djMXS5cbQbcxQmOOHk3Vf84AyzZ51AOjMF4l-p4u4dyJqRbyzSgJFhIoVnXqzjmiYFfeySaeQl8XdhOrNa_gb_jjRtdEw9HqTIosevNWNaYr1cdPTX-EC_t-Iv2Fc2pqVcRpPCI/s640/Image+009.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">and the Group has been added to the dimension pane</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxnxxGsgabQxWAZD_QsJkR7njQHXrMvRXSjrA1CQp-crPqqXieZN9BL-pUsHEYzCARZQjIX0sH61YMtoVM_UCkjMX0hyese77msVcFFidPYJTzYaK23-X4Q19ePv8HWfkoFktv5rH85CE/s1600/Image+010.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxnxxGsgabQxWAZD_QsJkR7njQHXrMvRXSjrA1CQp-crPqqXieZN9BL-pUsHEYzCARZQjIX0sH61YMtoVM_UCkjMX0hyese77msVcFFidPYJTzYaK23-X4Q19ePv8HWfkoFktv5rH85CE/s640/Image+010.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Grouping by joining a secondary file works when groups are changed infrequently or can be downloaded directly from another database. I used a similar approach to grouping products into subcategories and categories along a product hierarchy taken from an ERP system.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Grouping using a Calculated field</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">When the grouping can be described using a calculation the groups can be even more dynamic. The grouping by last name example can also be done using a calculation </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">left( split([Customer Name],' ',2),1)</span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaHj3ELIDZ6WQNzWV9jPm5eS8Q9DEJufCF3HhQA3TwmozPp5FvmB7xX_CbZuIVEHtZM5C0I81BLUzzaL9W8xWBVRP9VBb4_gI7iKIF_zaHS0Hl1897wzlqG4eDIN4LvqR3kUE8uUB8F9g/s1600/Image+014.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaHj3ELIDZ6WQNzWV9jPm5eS8Q9DEJufCF3HhQA3TwmozPp5FvmB7xX_CbZuIVEHtZM5C0I81BLUzzaL9W8xWBVRP9VBb4_gI7iKIF_zaHS0Hl1897wzlqG4eDIN4LvqR3kUE8uUB8F9g/s640/Image+014.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Grouping created by using a calculation are dynamic and change whenever the data are updated or changed</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Regardless of how they are created, groups give you a way to categorize the dataset. They can be used in hierarchies:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUbaPKK1DUBbTOmE3Ba4mjw7PVXEvXAW1N5zJoBgjnXcgKmqocPnCuSrqwbF7kIA91-w6uzA1gPdhcKJ99-CiTNYIqolrhvL1GaLLS_eUYXtNEoD9xVH8v3MUMA8AnqCKjjKptAgLLCAw/s1600/hierarchy+view.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUbaPKK1DUBbTOmE3Ba4mjw7PVXEvXAW1N5zJoBgjnXcgKmqocPnCuSrqwbF7kIA91-w6uzA1gPdhcKJ99-CiTNYIqolrhvL1GaLLS_eUYXtNEoD9xVH8v3MUMA8AnqCKjjKptAgLLCAw/s640/hierarchy+view.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">and can be filtered</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfuO4JUWrv25uXCtkt5Y-2mjPyL1u5BFzWfYC6WGC6WeCtLHuIcVN9EMFX-wA9MSITgS8Ush2d_yoDULowGvcfW1uZ8vRcimXpQyiZ26cOSxVi-8sw1cISWeNsWCZkbfpiWnAtWXXH7Gs/s1600/filtered+group.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="746" data-original-width="869" height="342" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfuO4JUWrv25uXCtkt5Y-2mjPyL1u5BFzWfYC6WGC6WeCtLHuIcVN9EMFX-wA9MSITgS8Ush2d_yoDULowGvcfW1uZ8vRcimXpQyiZ26cOSxVi-8sw1cISWeNsWCZkbfpiWnAtWXXH7Gs/s400/filtered+group.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">or can be used in calculations</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6_bkLbkAAoWFfEvh0IPaUMQ8CqrFTq7b4bOBsus-p2NLKL_FqUo2w00vhnoLSfno3VFEwOTFyvmz5fsJfFCsI5RcIQitziDt6QSEEa5j0-ZX6nAhoa4qGCstMMvhbcsnI5ommz60CT-E/s1600/table+calc+example.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="684" data-original-width="505" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6_bkLbkAAoWFfEvh0IPaUMQ8CqrFTq7b4bOBsus-p2NLKL_FqUo2w00vhnoLSfno3VFEwOTFyvmz5fsJfFCsI5RcIQitziDt6QSEEa5j0-ZX6nAhoa4qGCstMMvhbcsnI5ommz60CT-E/s400/table+calc+example.PNG" width="295" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">I hope this gives you more insights for groups and how they can be used </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The workbook and calculations used in the examples can be downloaded at :</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/CreatingGroups_15867096863020/Dashboard1">https://public.tableau.com/profile/jim.dehner#!/vizhome/CreatingGroups_15867096863020/Dashboard1</a></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Enjoy</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Jim</span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-26009400385759562482020-03-25T08:19:00.000-05:002020-03-25T08:19:13.308-05:003 Dimension Charts<span style="font-family: "arial" , "helvetica" , sans-serif;">I'm a fan of 3-dimensional charts. You may be also and are familiar with how some spreadsheet systems have an option for 3 - Bar or line charts. I get it. Some business managers just see the story better that way and besides they are cool.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Well, Tableau doesn't have a standard 3-D chart type but with some prep work on the data and extending the data densification concepts used to plot curves it is possible to get close.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">To start if you are not familiar with data densification, Ken Flerlage has done an outstanding job of presenting the topic in a straight forward and understandable way - see: </span><a href="https://www.flerlagetwins.com/2019/05/intro-to-data-densification.html">https://www.flerlagetwins.com/2019/05/intro-to-data-densification.html</a><br />
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">To extend those concepts to 3 dimensions think about a cube rotated in space and projection the position of points on the cube back to the 2-D display </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx1H_2EM16TL9M27BxWsvHHFwy7bUfFKcus6TvaV9fXVlfT0qDdStA6BaIC8JGZUq87RdXlo5Oh1NmlkBOcUiz4dasI3Kb7M6ZQ5grqzmHehSGyK7y7EjxyM98r82T_1zd4QYX1_YctyA/s1600/3+D+cube.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="536" data-original-width="831" height="206" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx1H_2EM16TL9M27BxWsvHHFwy7bUfFKcus6TvaV9fXVlfT0qDdStA6BaIC8JGZUq87RdXlo5Oh1NmlkBOcUiz4dasI3Kb7M6ZQ5grqzmHehSGyK7y7EjxyM98r82T_1zd4QYX1_YctyA/s320/3+D+cube.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Points on the cube are transferred back to the viewing plane using the cube's rotation around the horizontal and vertical axes. There is some math involved and for those who really understand 3D projection, the approach is not a true prospective - just a transfer of point onto a 2D XY plane.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">There are a series of calculations that are needed (I will include them here but a downloadable copy of the workbook will be on my Tableau Public site - and you can just copy them from the book) Using Superstore dimensions fore Order Date and Sale and relating them to the X, Y and Z dimensions of the cube:</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
</div>
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Month numbers 1-12 are the X cube axis</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">The Sum(Sales) in Thousands are on the Y cube axis </span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">The Years are the reference on the Z cube axis 2017 = 1, 2018 = 2 etc </span></li>
</ul>
<br />
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Data Structure</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">After duplicating, data restructuring is needed - In each year (Partition) the original data are sequenced low to high and the copy high to low:</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDTQSCdQsfWFRYJmptivXoPG-esUzN7dIEEQOciRXMAwue_POvwAirotqybiCyLrU7OLfSLOSBT99-XK3bQO0CDPmisuBkW584Lt7VoGsHaVFcQktgvfsmvVt5Tvb_LeCLU7oNSp_gEw0/s1600/new+data+sequence.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="512" data-original-width="528" height="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDTQSCdQsfWFRYJmptivXoPG-esUzN7dIEEQOciRXMAwue_POvwAirotqybiCyLrU7OLfSLOSBT99-XK3bQO0CDPmisuBkW584Lt7VoGsHaVFcQktgvfsmvVt5Tvb_LeCLU7oNSp_gEw0/s320/new+data+sequence.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The data are grouped by Year(Order Date) the Z value is just an way to increment the year along the Z axis 1 for 2017, 2 for 2018 etc - </span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">With Tableau Prep the copying, sequencing and restructure the data can be accomplished in a few steps</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimhtphMXAMUuW4k4bePyHyyd8OodgcvvrYdRQX8c5OxvVFt5_9uAn7Ty5MCrN7WAz0X77GCi0nUEDQBoqcTHsGvUQHnLL7VAeCASiCwY3UOm10DDIAnJAl8pj1sSlzsmCdtAyg858RgTU/s1600/Prep+Overview.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimhtphMXAMUuW4k4bePyHyyd8OodgcvvrYdRQX8c5OxvVFt5_9uAn7Ty5MCrN7WAz0X77GCi0nUEDQBoqcTHsGvUQHnLL7VAeCASiCwY3UOm10DDIAnJAl8pj1sSlzsmCdtAyg858RgTU/s640/Prep+Overview.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">1- Bring 2 copies of the data - The original file needs no changes - Sequence is from Min X to Max X values</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">2 - In the Copy - the data Sequence numbering needs to be from the Max X value to Min X</span></div>
<div class="separator" style="clear: both;">
</div>
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Determine the Max Z value ( Here 4) : { FIXED :max([Z])}</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Find the Total number of records : {{Fixed Year : Countd([Month(X)]}}</span></li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibmWTYnpNpGdhzW6xSZlWua-nFe-itNAH_XTcN9iucQcWFROdYc2mUe4yzg2Ll20CiTSKvsqUGkQ6eHrowivRaEHMoTsDD-6oS96DnQvzeuujpZRQpNTzrX1G-x4KiWzN0rXWS-Wkubm8/s1600/Count+in+prep.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="358" data-original-width="801" height="143" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibmWTYnpNpGdhzW6xSZlWua-nFe-itNAH_XTcN9iucQcWFROdYc2mUe4yzg2Ll20CiTSKvsqUGkQ6eHrowivRaEHMoTsDD-6oS96DnQvzeuujpZRQpNTzrX1G-x4KiWzN0rXWS-Wkubm8/s320/Count+in+prep.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
</div>
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Renumber the "New Sequence" : (([fix max z]+([Z]-1))*[Fixed LOD1])+(([Fixed LOD1]+1)-[month(x)])</span></li>
</ul>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">3- Union the files and revise names and remove unneeded columns</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaPyxu6xLnvYR_1OeBLXZ0VmAMu0SZOqhOYxkoH0ypketybPIPUwO_0IK5Mptm_dcw5U0oVrBDXS3vdCkUgE6JYJ2Saijc-AYkmtykrWLajwxiuowz5r5HN-_oexwxaURSvVNnCN3UpbU/s1600/prep+union.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaPyxu6xLnvYR_1OeBLXZ0VmAMu0SZOqhOYxkoH0ypketybPIPUwO_0IK5Mptm_dcw5U0oVrBDXS3vdCkUgE6JYJ2Saijc-AYkmtykrWLajwxiuowz5r5HN-_oexwxaURSvVNnCN3UpbU/s640/prep+union.png" width="640" /></a></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<br />
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">4- In the final step convert all the Y values from the copy data set to 0 :</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">if [Table Names]="Table 1" then [Sales/1000 (Y)] else 0 end</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then output a file for Tableau - </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Transformation Formulas </b></span></div>
<br />
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Set up 2 parameters for the rotation around the Horizontal (view X axis) and Vertical (view Y Axis) -</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEki5ZqDjkqE10Kb6A6EnrA3EL0s7ChXMVsEwpLL6tBdxccbWfEaWO1cyGyu9MmT0KNyBIgC7Xy7nhsrwki3ZI48jvXH1JoRBobfP4aKaigFhMFHzL6E1WvdaqvuHEFcxa5kPAZ1Zbabg/s1600/rotation+parameters.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="405" data-original-width="556" height="233" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEki5ZqDjkqE10Kb6A6EnrA3EL0s7ChXMVsEwpLL6tBdxccbWfEaWO1cyGyu9MmT0KNyBIgC7Xy7nhsrwki3ZI48jvXH1JoRBobfP4aKaigFhMFHzL6E1WvdaqvuHEFcxa5kPAZ1Zbabg/s320/rotation+parameters.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Tableau uses radians, convert the parameter values to radians:</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Vertical axis rotation : ([Vertical axis rotation (degrees)]/360)*2*pi()</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Horizontal axis rotation : -([Horizontal axis rotation]/360)*2*pi()</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Note the negative sign on the horizontal rotation </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The transformation of point to the 2D X dimension is </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">-([Month(X)]*cos([vert axis radians])-(3*[Z])*sin([vert axis radians]))</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">and for the 2D Y dimension</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">-(cos([hor axis radians ])*[Sales/1000 (Y)]</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">-[Month(X)]*sin([vert axis radians])-([z axis gap]*[Z])*cos([vert axis radians]))</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Note the Z parameter for the "Z axis gap" is a parameter to adjust the spacing in the final viz.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Create the Viz</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The VIZ uses the 2D X and Y calculations on columns and rows - add Z to the detail marks card and Sequence to path - </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">I include the axis rotation and Z Gap spacing parameters to allow the user to adjust the view</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLBOqp2WbhZThYvD9xToiTy481QrDOEUHsTCgXC9K-D_jAY0cOzSNWHv92lfJnVZ-DZIRSOf-VfJdFen8V5Wxa4joVq1cS9Vxm3OfiA3HYS2_FFSHHSS3B0IupjrGDkQ0PU4jdMMgJGmk/s1600/3D+chart+sample.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLBOqp2WbhZThYvD9xToiTy481QrDOEUHsTCgXC9K-D_jAY0cOzSNWHv92lfJnVZ-DZIRSOf-VfJdFen8V5Wxa4joVq1cS9Vxm3OfiA3HYS2_FFSHHSS3B0IupjrGDkQ0PU4jdMMgJGmk/s640/3D+chart+sample.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">When creating the dashboard I used sheet swapping and added a "Change parameter" set to hover for navigation </span></div>
<div class="separator" style="clear: both;">
</div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixpJEwNUTgb-PjJCRkrrA3wZVWC98pWB2H56ExqGbfcp8J0uWISYmwp9h_RiRXJU_xJabaA50kJjZx5RTAWk_c06waMDwfFFtztWlVIKm8iMWAi8ShQfPG78CLL06Lh8oKThf6HV0ljKk/s1600/final+d-b.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="829" data-original-width="1023" height="518" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixpJEwNUTgb-PjJCRkrrA3wZVWC98pWB2H56ExqGbfcp8J0uWISYmwp9h_RiRXJU_xJabaA50kJjZx5RTAWk_c06waMDwfFFtztWlVIKm8iMWAi8ShQfPG78CLL06Lh8oKThf6HV0ljKk/s640/final+d-b.PNG" width="640" /></a></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Would love to hear from you on this and see what you have done</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The sample workbooks can be downloaded from </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/ThreeDimensionalDisplay/Param3Ddb">https://public.tableau.com/profile/jim.dehner#!/vizhome/ThreeDimensionalDisplay/Param3Ddb</a></span></div>
<br />
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Enjoy</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Jim</span></div>
<div class="separator" style="clear: both;">
<br /></div>
www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-30667724770461337182020-03-24T09:22:00.002-05:002020-03-24T14:48:07.885-05:00FAQ Series Order of Operations<span style="font-family: "arial" , "helvetica" , sans-serif;">So Just how does the Order of Operations affect your calculations?</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Tableau, like most systems has an order or sequence in which filters are applied and calculations are executed. The process starts at the top and proceeds to the bottom in a single pass. Calculations executed lower in the order depend on all the steps that precede them. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuQu-J0CARaOos9PJckOuBMh9Qa9VKU9mYp1oP6Zd3svCY5GkSQLvL6Xmfrba5zMCId0-vuWDIFKRFLN7SLo1_SNKd1M4fY06qxYASovGNfbhD7hvLhM138JfpK_YMRbaKpZQtBY7SL0E/s1600/new+ooo+slide.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="716" data-original-width="1281" height="356" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuQu-J0CARaOos9PJckOuBMh9Qa9VKU9mYp1oP6Zd3svCY5GkSQLvL6Xmfrba5zMCId0-vuWDIFKRFLN7SLo1_SNKd1M4fY06qxYASovGNfbhD7hvLhM138JfpK_YMRbaKpZQtBY7SL0E/s640/new+ooo+slide.PNG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Steps 1 and 2 - Extract and Data Source Filters</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">First just a quick work on the first 2 filters - Extract and Data Source work as data is loaded from the source and limit the amount of data available workbook. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">The remaining filters are executed in the context of a worksheet and limit the data that is included in the table that underlays that sheet - filters on a worksheet can be applied to other sheets to limit the underlying table on those sheets also.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Step 3 - Context Filters:</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Placing a dimension "In Context" will apply the filter before any calculations are executed, the Top N is determined or Sets are formed. - The data associated with the filter is not on the worksheet's underlying table and is therefor not available to remainder of the order of operation.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Just open the drop down and select Add to Context</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGOG8Qd0FnGcA05cJ28Ri6hNlmP8sayedV8rPyPn7q6MZTFbHs6XzgmVYgbZS0HW-rKfuF0zUMSkNphsiW9GOy1w0I4oVcXHsCqMRboFsGUz7lv1WcbSH09wPTvN8YPbeAzLv8Q48N77o/s1600/add+to+context.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="381" data-original-width="615" height="247" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGOG8Qd0FnGcA05cJ28Ri6hNlmP8sayedV8rPyPn7q6MZTFbHs6XzgmVYgbZS0HW-rKfuF0zUMSkNphsiW9GOy1w0I4oVcXHsCqMRboFsGUz7lv1WcbSH09wPTvN8YPbeAzLv8Q48N77o/s400/add+to+context.PNG" width="400" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Step 4 Sets, Fixed LOD and Top N</b></span> <span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">I'm going to use this simple table in the next few examples to show the affect of context filters</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijh10C9KgouZ_Ekfny8efEQyy0Qktq36zaj4LMdZGzqu9OcItwgses3D8T7yCyP2Pgc6afiTTpTw6Yz5DLoqN8QoI7lG3i5QOL-J_pVylTBABjMaZvhGtnu3KkUuuclVub7NpXHVggcgI/s1600/example+1+start.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="138" data-original-width="456" height="120" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijh10C9KgouZ_Ekfny8efEQyy0Qktq36zaj4LMdZGzqu9OcItwgses3D8T7yCyP2Pgc6afiTTpTw6Yz5DLoqN8QoI7lG3i5QOL-J_pVylTBABjMaZvhGtnu3KkUuuclVub7NpXHVggcgI/s400/example+1+start.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">After adding Total Cost = (Price*Quantity) and an LOD: </span><span style="font-family: "arial" , "helvetica" , sans-serif;">{ Fixed Type :sum(Total Cost)}</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">A text chart like this would result with no filters applied - and the LOD value for Fruit is 5.75</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgUQm-yVS9rAiX1h4-4ATgIs2feJuOUihlRHf0lPoRwZfXGHZ6C3DGI2DHmt43J2t-V2f9SBi6SHjiYilX_GNv-5shV9SYiDqP1FtP1hUspwik1Ic-Q32tuF4heAYoJsvcbM379ufNl0M/s1600/new+first+view+of+data.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="546" data-original-width="869" height="251" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgUQm-yVS9rAiX1h4-4ATgIs2feJuOUihlRHf0lPoRwZfXGHZ6C3DGI2DHmt43J2t-V2f9SBi6SHjiYilX_GNv-5shV9SYiDqP1FtP1hUspwik1Ic-Q32tuF4heAYoJsvcbM379ufNl0M/s400/new+first+view+of+data.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now see the Context filter effect on the LOD - </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Start without the Produce Name in Context, Banana has been filter out but the but the LOD value remains unchanged - the LOD is calculated before the dimension filter is applied</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaSAMqjgeu3O27I9tKLUGSpxkME0_kSSjqoQSD_01RmAMwUr4q97gozSOMip3pV5vSGxULXo7mzw0Fplu1lMIv6Lm1bNwdlNvS6hKgYiOErIgjN1RsXnrVNgUJ06PC7NljJdKFeFVmPbU/s1600/LOD+Start.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="751" data-original-width="1056" height="283" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaSAMqjgeu3O27I9tKLUGSpxkME0_kSSjqoQSD_01RmAMwUr4q97gozSOMip3pV5vSGxULXo7mzw0Fplu1lMIv6Lm1bNwdlNvS6hKgYiOErIgjN1RsXnrVNgUJ06PC7NljJdKFeFVmPbU/s400/LOD+Start.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Place Produce Name in Context </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Banana is filtered out in the Context filter before the LOD is calculated so the count of values in Fruit is now just 2 and the LOD total is reduced to 3.75 - </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQMNV7uoHvvRB7xZ-pIwvF_RVbJ-jLODPa7JBDrd5zPnEVX-OMtYI5kapoh59UifmZzAQ4VKn_-beswm5GxmVgs3a3UmmcX0DYdQDMjzHNrdDAbXS0qXO0CQoIatCv3NCpDyE_DYWn6Jc/s1600/After+lod.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="766" data-original-width="1043" height="293" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQMNV7uoHvvRB7xZ-pIwvF_RVbJ-jLODPa7JBDrd5zPnEVX-OMtYI5kapoh59UifmZzAQ4VKn_-beswm5GxmVgs3a3UmmcX0DYdQDMjzHNrdDAbXS0qXO0CQoIatCv3NCpDyE_DYWn6Jc/s400/After+lod.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Sets are affected by using a context filter also. The set will contain the Top 3 Produce Names</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC4mEsKWpf53BbIMGBqeAvjzbuXRlpvuQknDxMfAHKCk3XUvRf9qJM0z0XrIxCs9e_506d_5K4OcuL835N1ojyOsDPOaiXj4t4HMKMpkJlANmYkNl0vRgByVtE5xB9z7ZoD1thLSWUSaA/s1600/set+top+3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="594" data-original-width="457" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC4mEsKWpf53BbIMGBqeAvjzbuXRlpvuQknDxMfAHKCk3XUvRf9qJM0z0XrIxCs9e_506d_5K4OcuL835N1ojyOsDPOaiXj4t4HMKMpkJlANmYkNl0vRgByVtE5xB9z7ZoD1thLSWUSaA/s400/set+top+3.PNG" width="307" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">With no filters applied and nothing in the Context filter, Apple, Banana and Green Beans are the Top 3</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIo1nhcbqrWF5jfZ1Ej-Pfgisbf4poabEcKxPq7_Xw6RRci40feOF294zrmQ7UKlTq-t5B0tfcvSTUaN_s_LVDqjOfNU7gR16SvnM4Nx4SQWqDnPzCUSIOitVGNQjrdcYRXTyIv6H0zRY/s1600/sets+starting+point.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="769" data-original-width="1091" height="281" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIo1nhcbqrWF5jfZ1Ej-Pfgisbf4poabEcKxPq7_Xw6RRci40feOF294zrmQ7UKlTq-t5B0tfcvSTUaN_s_LVDqjOfNU7gR16SvnM4Nx4SQWqDnPzCUSIOitVGNQjrdcYRXTyIv6H0zRY/s400/sets+starting+point.PNG" width="400" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">If we filter out Banana without placing Produce Name in Context only Apple and Green Beans are in the result - 2 Produce Names - Not 3? </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The Set is determined on the entire data set - before the Dimension filter is applied - Later, after the Set is formed Banana is filtered out </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">But if Produce Name is placed in Context and Banana is filter out before the set is formed 3 values are returned Apple, Green Beans and Spinach (Remember Banana is no longer in the data table for the worksheet)</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidVdPmqDyjS5HAX3KbSaRyTxt1h-VdMUfYJlhZ7-W2RGc7tshRU55LyBb0AIbqa_3yym8CShGaz52pp6tVWjVIF1YfuJ6okwWbfzJYcGDPZideNJUePVVeKfnyl8m98-DncfQWjGPjje0/s1600/sets+final.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="792" data-original-width="1107" height="285" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidVdPmqDyjS5HAX3KbSaRyTxt1h-VdMUfYJlhZ7-W2RGc7tshRU55LyBb0AIbqa_3yym8CShGaz52pp6tVWjVIF1YfuJ6okwWbfzJYcGDPZideNJUePVVeKfnyl8m98-DncfQWjGPjje0/s400/sets+final.PNG" width="400" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Let's see what happens with a Top N Filter</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Start with a filter on Produce Name set for Top N =3</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-teJ6_bfLZ2tOV18i2Q-bEV4RrxPTqTEuXy2N-MvPlch3aYkiQ3lmz__8_noAGGO-FbNTg0Ntpgbbmxek7vgI7eZ6iP9jlVxPT2IsU8FsiAS9YfnDDQA_fV7ZE_fzvIVajtpKbodFeXg/s1600/top+n+filter+setup.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="567" data-original-width="455" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-teJ6_bfLZ2tOV18i2Q-bEV4RrxPTqTEuXy2N-MvPlch3aYkiQ3lmz__8_noAGGO-FbNTg0Ntpgbbmxek7vgI7eZ6iP9jlVxPT2IsU8FsiAS9YfnDDQA_fV7ZE_fzvIVajtpKbodFeXg/s400/top+n+filter+setup.PNG" width="320" /></a></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<br />
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Create a viz and add a filter on Type - with no filters applied and nothing in Context.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The Top 3 are Apple, Banana and Green Beans </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKIedvs-DimS00r8cL3YcfAK0YWxl-uUYTXT5kCJabyBb4Rw51aQUxk4iRyX1OwlKXWvwgaLy4IYD4FT6x-SJV8DxqHcHzwY4i-8rBS9CRE22KUtRKcQewyXJ7M3HrP1edlDLnmeSSLk4/s1600/top+n+filter+start.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="786" data-original-width="977" height="321" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKIedvs-DimS00r8cL3YcfAK0YWxl-uUYTXT5kCJabyBb4Rw51aQUxk4iRyX1OwlKXWvwgaLy4IYD4FT6x-SJV8DxqHcHzwY4i-8rBS9CRE22KUtRKcQewyXJ7M3HrP1edlDLnmeSSLk4/s400/top+n+filter+start.PNG" width="400" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Filter out Vegetable from Type but do not place in Context</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhh_29ZHRlHQpGzvtKF06xk8XZt2VEL7D5T0XvarLVDDOH8FVSB_RkGfdk21d9uhf5uyrHNLeWF48VOLj6lsxKaywDOn20arLYRUyZn8yfbzvekr1pAxYtbfsMfvAEyVnQQxLgJ_FaW-rU/s1600/top+N+filter+out+no+context.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="760" data-original-width="989" height="305" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhh_29ZHRlHQpGzvtKF06xk8XZt2VEL7D5T0XvarLVDDOH8FVSB_RkGfdk21d9uhf5uyrHNLeWF48VOLj6lsxKaywDOn20arLYRUyZn8yfbzvekr1pAxYtbfsMfvAEyVnQQxLgJ_FaW-rU/s400/top+N+filter+out+no+context.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">And only 2 values are returned Apple and Banana - the three Top N values were determined before the Dimension filter is applied - and included 1 vegetable - Green Beans.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Later when the Dimension filter filters out Vegetable there are only the 2 Fruit values remaining in the Top N</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Bu when Vegetables are filter out in Context, the Top N are determined only from Fruit and 3 values are returned - Apples, Bananas and Grapes - </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRFAUkfuYoV1a_-S6w1lEwvb7l75CZOnJWYoAt8buJVDSjCGDKZ8WWx3NpKoBG9H3IZsNfIqT6E5wwzSiEeqV_HzPJ0GQQC1I1eQtOOSdO8LJYtvBhHB0AQkjO-SKGraMGefoTbkHTY7E/s1600/top+3+in+context.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="766" data-original-width="931" height="327" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRFAUkfuYoV1a_-S6w1lEwvb7l75CZOnJWYoAt8buJVDSjCGDKZ8WWx3NpKoBG9H3IZsNfIqT6E5wwzSiEeqV_HzPJ0GQQC1I1eQtOOSdO8LJYtvBhHB0AQkjO-SKGraMGefoTbkHTY7E/s400/top+3+in+context.PNG" width="400" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Step 5 - Dimension Filters</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Dimension filters come in a discrete and a continuous version - The discrete dimension filter should feel familiar if you have ever used a filter on a spreadsheet. The process is the same - just select the dimension values to include in the view - <b> </b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Using the Superstore data set that came with Tableau </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Start with a simple bar chart of sales by year and segment - no filters applied </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizaStMUBA89lnrtIEmDa52RDLhP3eExGJn22kySsgpPtdWLMIdgG1ox4eGF9rXAvaT4SAq0fXfqfaS1Qpk7JebTqINzv5UrGXNWjYb2oq9bEa3cLrAY1LKVAbnW_5RLw1DDFf6yvw7ncI/s1600/discrete+dimension+start.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="560" data-original-width="1600" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizaStMUBA89lnrtIEmDa52RDLhP3eExGJn22kySsgpPtdWLMIdgG1ox4eGF9rXAvaT4SAq0fXfqfaS1Qpk7JebTqINzv5UrGXNWjYb2oq9bEa3cLrAY1LKVAbnW_5RLw1DDFf6yvw7ncI/s640/discrete+dimension+start.PNG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Apply a filter on Segment and the segment is removed from the view - </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg74XJdHH_TGUqIi1ROSTHkthN3wKDKaZeTY5pfLgm3vnfkaRvQ4q3FtNnjc0M0Llqss4aS2ZMMPYCoHja-8mN_dBxUVtkto9DN-2KNfXyRixtiuVqIRPcVcrJDDVXKl_3jhIbQO9tJwZI/s1600/discrete+dimension+end.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg74XJdHH_TGUqIi1ROSTHkthN3wKDKaZeTY5pfLgm3vnfkaRvQ4q3FtNnjc0M0Llqss4aS2ZMMPYCoHja-8mN_dBxUVtkto9DN-2KNfXyRixtiuVqIRPcVcrJDDVXKl_3jhIbQO9tJwZI/s640/discrete+dimension+end.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The dimension does not need to be on the rows or the columns in the view - the data will will be filtered from the data table and the view adjusted</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQp6ApCvZ2l8DQ4mVfAgDiUv2Utk1IJnbnzYZkn1NimswpEho4SJwY0ieZV9VZ-N2TbT1gTAl7sixiNub5VYGG9SrHBcLctwLBn1BhEPn41-6HEAxJM5NDaWOvcilluaWvrvF_lScRUj8/s1600/dimension+discrete+not+in+the+view.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQp6ApCvZ2l8DQ4mVfAgDiUv2Utk1IJnbnzYZkn1NimswpEho4SJwY0ieZV9VZ-N2TbT1gTAl7sixiNub5VYGG9SrHBcLctwLBn1BhEPn41-6HEAxJM5NDaWOvcilluaWvrvF_lScRUj8/s640/dimension+discrete+not+in+the+view.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Dimension filters can also be applied to continuous data - Here a range filter with start and stop dates to a date field </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVQ-rjkHN75XTUSt2GC7lhiAV7RGo5jbdWJtmGIkIzaTYEhh0zEPO8t8limI1Q_8Yez2ZUAu8hFboKmlvJyt2owch6Huqz1_geGzXelhQnR5f_J9insi8mqIl6nA8OwxkPBi1cbeUEwDg/s1600/range+filter+continuous.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVQ-rjkHN75XTUSt2GC7lhiAV7RGo5jbdWJtmGIkIzaTYEhh0zEPO8t8limI1Q_8Yez2ZUAu8hFboKmlvJyt2owch6Huqz1_geGzXelhQnR5f_J9insi8mqIl6nA8OwxkPBi1cbeUEwDg/s640/range+filter+continuous.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Or as a relative filter - like the last 6 Quarter shown below</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiYmLK7suAXVikfGasH512gm9J6CyvBtQM1bQW9Jmtoqmp9VC3dWqYVMmz_oIWHhAPkfZwq-hDaRtmAZBxGm6uCvXosvQv7yPfunyL4657gEbxaVxf9KMv3wlUpX33stKGkiQkgGDnCPA/s1600/relative+date+filter.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiYmLK7suAXVikfGasH512gm9J6CyvBtQM1bQW9Jmtoqmp9VC3dWqYVMmz_oIWHhAPkfZwq-hDaRtmAZBxGm6uCvXosvQv7yPfunyL4657gEbxaVxf9KMv3wlUpX33stKGkiQkgGDnCPA/s640/relative+date+filter.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Dimension filters are applied to the underlying table for the worksheet after the context filter and set, top N and Fixed LOD calculation noted earlier. After they have been applied the table has been set and further calculations or filters are only applied to values in the table .</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Step 6 - Data Blending</b> </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The topic is much too broad for a full discussion here but note where Blending occurs - After Fixed LOD's and dimension filters have been applied. Blending results in data that is aggregated at the level of the link (relationship) among the data sets - but further dimension filtering or use of LOD's across the blended data sets is not available.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Step 7 - Include and Exclude LOD's</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Include and Exclude are the less frequently used pair of LOD expressions -</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Based on their position in the Order of Operation they operate on the data table that results after the application of all Dimensional and context filters -</span><span style="font-family: "arial" , "helvetica" , sans-serif;">- </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">So if the table is what what do they do</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Include and Exclude refer to the visible portion of the table that is in the Viz - Include will use dimension in the table NOT visible in the viz into the calculation - Exclude will not use dimensions visible in the view -- </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Lets see how they work:</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">For these examples, we will use a small product sales data set - 2 Customers, 2 Product Lines, 4 Products and a variety of colors</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr_DufyaE2o8SwI-5OY_IFTp46JWLD1p_MDlwI_Ge67UfhcqaAkCsaaooKByeDGzn97pyZ8sunfNDLNLtG47VvR-hhtxOTgI0Jpq5M3iHQZgNDbaTJrD0IsTBPFJLxzAjuqKccQARS-g8/s1600/prod+lin+input.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="288" data-original-width="525" height="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr_DufyaE2o8SwI-5OY_IFTp46JWLD1p_MDlwI_Ge67UfhcqaAkCsaaooKByeDGzn97pyZ8sunfNDLNLtG47VvR-hhtxOTgI0Jpq5M3iHQZgNDbaTJrD0IsTBPFJLxzAjuqKccQARS-g8/s400/prod+lin+input.PNG" width="400" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Add an Include LOD at the Product level - </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBPNHSZpMdkimMhBADGiG0ZrfA9IyrnDIrQpoljs9QzGVn5kLTtCJVVT3ju8L6OaN6afzOnNrInMQ7R-MM76w_VrKQ4Wa-58r7OaYxVGIgiqVtgi_Cp0M9Qh2wB3VW9vQX94RjkW0eXaI/s1600/Include+prod+statement.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="139" data-original-width="423" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBPNHSZpMdkimMhBADGiG0ZrfA9IyrnDIrQpoljs9QzGVn5kLTtCJVVT3ju8L6OaN6afzOnNrInMQ7R-MM76w_VrKQ4Wa-58r7OaYxVGIgiqVtgi_Cp0M9Qh2wB3VW9vQX94RjkW0eXaI/s640/Include+prod+statement.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">When the viz includes the Product level and lower the average from the LOD and a simple average on quantity return the same result</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT8Rv6KQWIS0o7PDcD0WjW9NS7rxOCGdK7Kl0Kfl5CaHSj5cK39czz8IYQLsj4jIxqh_M-bk87Q4XJIkmu265VNmtnuw80_9V8uQpuVbFHXMpLv9RA8wFeeKIbPm7gAcRcJCK0OX9ZKvw/s1600/start+include+product.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="461" data-original-width="1028" height="286" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT8Rv6KQWIS0o7PDcD0WjW9NS7rxOCGdK7Kl0Kfl5CaHSj5cK39czz8IYQLsj4jIxqh_M-bk87Q4XJIkmu265VNmtnuw80_9V8uQpuVbFHXMpLv9RA8wFeeKIbPm7gAcRcJCK0OX9ZKvw/s640/start+include+product.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">As the hierarchy is compressed the value from the LOD is fixed at the product level</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYPmYLQoihcjkBNBvkXGCPhxGo1gK4Y11uPcL-THWHB634yGpS964LpV6LV02UOKYjeNaS2nreR2OZrRlXRR2OdfxomE4Odi-9N4hXmQiRENKIohikRhmS7L25xh7ioypGSB58o9VFQ-I/s1600/inlcude+slide+2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="492" data-original-width="942" height="334" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYPmYLQoihcjkBNBvkXGCPhxGo1gK4Y11uPcL-THWHB634yGpS964LpV6LV02UOKYjeNaS2nreR2OZrRlXRR2OdfxomE4Odi-9N4hXmQiRENKIohikRhmS7L25xh7ioypGSB58o9VFQ-I/s640/inlcude+slide+2.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">and return the average at the product level even when it is no longer in the view</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp4iEDQIS83nF0v9fBfWjmX2zaFPVNOZL5xOb-Ii9Mls5t2A2UHpYNQ4sRIeorH_bm8KXa4UrQPdMwVHGc3kpzBN4Ru6vYN3_-3JlRF4hweUxodCLTfk0Crlf5bjHGmRwMbkCfZ_eLUk0/s1600/include+slide+3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="473" data-original-width="789" height="382" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp4iEDQIS83nF0v9fBfWjmX2zaFPVNOZL5xOb-Ii9Mls5t2A2UHpYNQ4sRIeorH_bm8KXa4UrQPdMwVHGc3kpzBN4Ru6vYN3_-3JlRF4hweUxodCLTfk0Crlf5bjHGmRwMbkCfZ_eLUk0/s640/include+slide+3.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Exclude will eliminate the dimension from that calculation and the expression will be based on the next higher level in the view</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">With the same data set and</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUEJ30XqUsjl7WZ6gLpx8whWhW3wH9AM2Chb_16ycIxhhIRb_ccqGFrgnc5_aIqBX88zfnE5vMyVYt6FE2ptizG8OJFoeqXIUd4RRyh0Xr66QBBooxFPTsTtZHfiRqqnVSRmbIaCu8ZFU/s1600/exclude+statement.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="110" data-original-width="377" height="116" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUEJ30XqUsjl7WZ6gLpx8whWhW3wH9AM2Chb_16ycIxhhIRb_ccqGFrgnc5_aIqBX88zfnE5vMyVYt6FE2ptizG8OJFoeqXIUd4RRyh0Xr66QBBooxFPTsTtZHfiRqqnVSRmbIaCu8ZFU/s400/exclude+statement.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">will return this when the detail is below the level of Product - the same a simply summing the quantity</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ3iEmRuqmyMqdgRPJ6pj0qKAdLPTq22HpQByjNVtYxlMTwBjhrxERJCjzWvKX-oPdjoR5_Xx5ikT9fihzkjd5RvXTSuRvXt9ohFSe7KmhjbgOFTRZmFmmqcP2zLOHQn5gcmhabEIQrao/s1600/exclude+prod+result+1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="457" data-original-width="1051" height="276" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ3iEmRuqmyMqdgRPJ6pj0qKAdLPTq22HpQByjNVtYxlMTwBjhrxERJCjzWvKX-oPdjoR5_Xx5ikT9fihzkjd5RvXTSuRvXt9ohFSe7KmhjbgOFTRZmFmmqcP2zLOHQn5gcmhabEIQrao/s640/exclude+prod+result+1.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">but as the hierarchy is compressed the values is locked at the Product level</span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3EMvprVA92S_k4UWwBT0oGIsgJmGVnsQ7IwFKdDOODqX2fWchyphenhyphen2XIepyerYs-fu_rf8axd3ruXW0ZFbWosBzhS_vNJpBEusv7yOL0oqNQ8NfH0tBCaRJ29tkhNm1ukN-4I4GIBz9a0m0/s1600/exclude+result+2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="463" data-original-width="938" height="314" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3EMvprVA92S_k4UWwBT0oGIsgJmGVnsQ7IwFKdDOODqX2fWchyphenhyphen2XIepyerYs-fu_rf8axd3ruXW0ZFbWosBzhS_vNJpBEusv7yOL0oqNQ8NfH0tBCaRJ29tkhNm1ukN-4I4GIBz9a0m0/s640/exclude+result+2.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">and remains at that level </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKCPRt67z6xcuVqPAfc2Y3WWIjcw7V6WVvRhYiR-E03BcI_g5J76xRG8oRZJ6bCFbkobm64BO85Ff7znjmpsa00mip3JyXLL2ZCGkKPuYrpstDeTr8o7f-qCvwkLeOiTPjfkcUxD149wo/s1600/exclude+result+3.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="481" data-original-width="743" height="414" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKCPRt67z6xcuVqPAfc2Y3WWIjcw7V6WVvRhYiR-E03BcI_g5J76xRG8oRZJ6bCFbkobm64BO85Ff7znjmpsa00mip3JyXLL2ZCGkKPuYrpstDeTr8o7f-qCvwkLeOiTPjfkcUxD149wo/s640/exclude+result+3.PNG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Step 8 - Measure Filters</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Measure filters limit the view based on the values in the data table (not the categorization created by the Dimensions) and can be applied to the aggregate level or the row level data.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">When you drag the measure to the rows shelf a window will open giving you to filter at the Row Level "All Values" or at any of the noted levels of aggregation - </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBQQ1uor0_CAwxWUEbvJud-Ysa7lzu0CtSR-1fXVmrKXXStLkMrhqG8cbRqt3gNAA1pnEteBXhKwQHVIKGaVHLCu8pQSXBUyEBju9bGM8nVaHstJ4dZLnvBZMavLfPmuBVxUm4mjteUEs/s1600/setup+measure+filter.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBQQ1uor0_CAwxWUEbvJud-Ysa7lzu0CtSR-1fXVmrKXXStLkMrhqG8cbRqt3gNAA1pnEteBXhKwQHVIKGaVHLCu8pQSXBUyEBju9bGM8nVaHstJ4dZLnvBZMavLfPmuBVxUm4mjteUEs/s640/setup+measure+filter.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Continuing with the previous data set and filtering for the Sum(Quantity) - a continuous range filter will open - </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJljszXwEY8gM9s5J8SDhfsLvZjOn1IVFSG3Eg5KiDaSbEjjZ5YhjlE0Y4qSNn2-81eWjwbVkbGOz8mypwKd0KCK5mf_aFQKcoraFgEw0Js91lENGP0cDoVjFioH3OTxJC1oJhWePKR4E/s1600/measure+filter+start.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJljszXwEY8gM9s5J8SDhfsLvZjOn1IVFSG3Eg5KiDaSbEjjZ5YhjlE0Y4qSNn2-81eWjwbVkbGOz8mypwKd0KCK5mf_aFQKcoraFgEw0Js91lENGP0cDoVjFioH3OTxJC1oJhWePKR4E/s640/measure+filter+start.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Change the filter and any total value form the view that is not in the filter range is filtered out</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRHTm9ac-MIX3vji8f5Z6IEPSv5evR0G7_8iXYkPlVN7LhiBJJ-DHcGAvmDBLCFLlOR5kaaZ8PvNwMm1nv5VAPp-KJ_ewhSSSH3r4wlakJzqLGygiTo34Cl8_KGfzSO1UYjm7nXgthSk0/s1600/measure+filter+2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRHTm9ac-MIX3vji8f5Z6IEPSv5evR0G7_8iXYkPlVN7LhiBJJ-DHcGAvmDBLCFLlOR5kaaZ8PvNwMm1nv5VAPp-KJ_ewhSSSH3r4wlakJzqLGygiTo34Cl8_KGfzSO1UYjm7nXgthSk0/s640/measure+filter+2.png" width="640" /></a></span></div>
<br />
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">when the hierarchy is collapsed to Product Line the only 2 totals that in the range are 14 and 19 - the 94 and 62 are filtered out of the viz</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii6n6CLa06BXQ2rQ1q2_5B81Q-FJsJHLr81MQS2lwoZb_5XX7IxGE9cH8jZ68A7h_LxfnGurXMewFateDX72e1JxGSNXr-h-K4z-czvaAsTrdRxj0T4Cev4vDdBsHeIGRCSn_FV2RpoBU/s1600/measure+filter+3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii6n6CLa06BXQ2rQ1q2_5B81Q-FJsJHLr81MQS2lwoZb_5XX7IxGE9cH8jZ68A7h_LxfnGurXMewFateDX72e1JxGSNXr-h-K4z-czvaAsTrdRxj0T4Cev4vDdBsHeIGRCSn_FV2RpoBU/s640/measure+filter+3.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both;">
<br /></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Now, look at how the Row Level Measure filter produces a different result</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">The filter in NOT an aggregate (no SUM() around the measure)</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">But for this view the result is the same as the aggregate example</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOV3z70Q_4rQkR_bDFqFLUOc-o6UbHdYEogYxH92a4rw483VvXsHmPqn784Noy4gdyuExaSwUdmPIrlgHJOnnqWA5hpmKnmfqvsFEvWunv3v0J9q4wKMF5wto7-E9MLcYhptV0rNwx1a8/s1600/measure+row+level+1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOV3z70Q_4rQkR_bDFqFLUOc-o6UbHdYEogYxH92a4rw483VvXsHmPqn784Noy4gdyuExaSwUdmPIrlgHJOnnqWA5hpmKnmfqvsFEvWunv3v0J9q4wKMF5wto7-E9MLcYhptV0rNwx1a8/s640/measure+row+level+1.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Collapse the hierarchy as before the results are different - and 2 totals 37 and 55 are not filtered out - Why? - </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">The filter is applied at the row level in the data table and all the values between 10 - 35 are included - Then when the measure is brought to the viz they are summed - </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitPC0qMwLSw8HIqYR4iYSZB8bAWtA1sw3M53ektNfG00g5rwhb-1jvThA1Wevu3Bytt7vziU6aKAHvMmHgT4CMcoQMAhpxgCidLyXAPKEaLY8cApcO_PI20-wwsh8yV6dt6DLpqQkS624/s1600/meaure+row+level+2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitPC0qMwLSw8HIqYR4iYSZB8bAWtA1sw3M53ektNfG00g5rwhb-1jvThA1Wevu3Bytt7vziU6aKAHvMmHgT4CMcoQMAhpxgCidLyXAPKEaLY8cApcO_PI20-wwsh8yV6dt6DLpqQkS624/s640/meaure+row+level+2.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Step 9 - Grand Totals </b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Much like Blending Data - Grand totals are a large topic and will be addressed in a later posts - But note that Grand Totals are before Table Calculations - </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Step 10 - Table Calculations</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">As the name implies, Table Calculations are applied to the underlying table for the individual worksheet. At the bottom of the order of operations, they work with the fully filtered data and are always aggregates. They also can't be used in calculations that precede them in the order of operation - e.g. Table Calculations, Sets , or Top N - </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">They are extremely powerful tools used to compare data, total, look up or provide running sums across or within the data table -understand their position in the order of operation is at the bottom and the data table has been set. Using Table Calculations will be the subject on another FAQ so come back.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Hope this helps provide a better sense of what the order of operation is and how it is important when creating your viz</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: arial, helvetica, sans-serif;">A workbook containing the examples used here can be found and downloaded from </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/OrderofOperations_v2019_3/Dashboard3">https://public.tableau.com/profile/jim.dehner#!/vizhome/OrderofOperations_v2019_3/Dashboard3</a></span><br />
<br />
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Enjoy and let me know if you have questions</span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Jim</span><br />
<br />www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-38224904217217214652020-03-09T12:49:00.004-05:002022-01-24T08:54:13.726-06:00Parameters and Parameter Actions<div class="MsoNormal"><span face=""arial" , "helvetica" , sans-serif"><blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p></span></div><div class="MsoNormal"><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div class="MsoNormal">
<span face=""arial" , "helvetica" , sans-serif">Do you use parameters - I love them and use them a lot - Let's look at them in more detail</span></div>
<div class="MsoNormal">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="MsoNormal">
<span face=""arial" , "helvetica" , sans-serif">Parameters are one way users can directly input a value into Tableau. </span><br />
<br />
<span face=""arial" , "helvetica" , sans-serif">They are:</span><br />
<br />
<ul>
<li><span face=""arial" , "helvetica" , sans-serif">Single valued – have one value at a time </span></li>
<li><span face=""arial" , "helvetica" , sans-serif">Static the value is constant until manually changed by the user </span></li>
<li><span face=""arial" , "helvetica" , sans-serif">Global – they are available for use throughout the workbook.</span> </li>
</ul>
</div>
<div class="MsoNormal">
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">But they don’t do anything until they are used in a calculation, a set, or a filter. </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The same parameter can be used in any mix of calculations or filters on a single any combination of worksheets or dashboards. Changing the value of the parameter will change the calculation or filter wherever it is used. The change takes places as the sheet is opened.<o:p></o:p></span></div>
<div class="MsoNormal">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span face=""arial" , "helvetica" , sans-serif">There are 3 steps to follow when using parameter</span><br />
<br />
<ul>
<li><span face=""arial" , "helvetica" , sans-serif"><b>Create it</b></span></li>
<li><span face=""arial" , "helvetica" , sans-serif"><b>Put it in the viz</b></span></li>
<li><span face=""arial" , "helvetica" , sans-serif"><b>Use it in a calculation or filter</b></span></li>
</ul>
</div>
<b style="font-family: arial, helvetica, sans-serif;"><br /></b><b style="font-family: arial, helvetica, sans-serif;">1-Create it</b><br />
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span>
<div class="MsoNormal">
<span face=""arial" , "helvetica" , sans-serif">Parameters can be created directly from the data<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMGZGVexjB7I8UaTo6jKkni7kTyIyldaE2hBs8HHZm0ff0NQkRylmqcFYoqajaVXESRbMXXn-GIlUHuoflXXwtU9xXUQGCLL75mJmXJ5icawp-cRUJiHSebkvub7Z5YPhyzMwvqVoweZ0/s1600/Open+from+dimension+pane.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="456" data-original-width="649" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMGZGVexjB7I8UaTo6jKkni7kTyIyldaE2hBs8HHZm0ff0NQkRylmqcFYoqajaVXESRbMXXn-GIlUHuoflXXwtU9xXUQGCLL75mJmXJ5icawp-cRUJiHSebkvub7Z5YPhyzMwvqVoweZ0/s320/Open+from+dimension+pane.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">Or from the Filter or Set Top N</span><span face=""arial" , "helvetica" , sans-serif"> </span><span face=""arial" , "helvetica" , sans-serif">tabs</span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="MsoNormal">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhm77z1r5otmTD344djn_7aBtBQQJ0ECAtaoVpA3wo3eDYGMkMkSxp9tMFnm-daqW2xqCt3MUNi0mdkm_VUS38w7Pmu8su4i1iaYgqXG4uiJ2NWoEaG_Bdxa5f_tWK6gpD6GaKyNwKCz8E/s1600/Open+from+top+N.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="387" data-original-width="580" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhm77z1r5otmTD344djn_7aBtBQQJ0ECAtaoVpA3wo3eDYGMkMkSxp9tMFnm-daqW2xqCt3MUNi0mdkm_VUS38w7Pmu8su4i1iaYgqXG4uiJ2NWoEaG_Bdxa5f_tWK6gpD6GaKyNwKCz8E/s320/Open+from+top+N.PNG" width="320" /></a></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="MsoNormal">
<span face=""arial" , "helvetica" , sans-serif"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<span face=""arial" , "helvetica" , sans-serif"></span><br />
<div class="MsoNormal">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="MsoNormal">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div>
<br /></div>
<span face=""arial" , "helvetica" , sans-serif">Select Create Parameter - when the window opens set up the parameter</span><br />
<div>
<ul>
<li><span face=""arial" , "helvetica" , sans-serif">Add a meaningful name that tells the user what to do</span></li>
<li><span face=""arial" , "helvetica" , sans-serif">Select a data type that matches that of the dimension you will use</span></li>
<li><span face=""arial" , "helvetica" , sans-serif">Load values into the parameter either typing directly or from the dimension</span></li>
<li><span face=""arial" , "helvetica" , sans-serif">Click OK and you are done</span></li>
</ul>
<div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSp_alNljEloisVbUeDpwiV0DPwZyOOGxtF6qYBteaphLWJUJmSIWD_Fj7x8yTXtI1Rz_0lIiPaNf52fgCLTM5ZEkUche-NKFJ2m7E2mBh7C-nBSbj9Khw5UlEqKhTt4xTqjn6vbXZ7JA/s1600/Parameter+setup.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="705" data-original-width="1178" height="382" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSp_alNljEloisVbUeDpwiV0DPwZyOOGxtF6qYBteaphLWJUJmSIWD_Fj7x8yTXtI1Rz_0lIiPaNf52fgCLTM5ZEkUche-NKFJ2m7E2mBh7C-nBSbj9Khw5UlEqKhTt4xTqjn6vbXZ7JA/s640/Parameter+setup.PNG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><b><br />2 Add the parameter to the viz</b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span><span face=""arial" , "helvetica" , sans-serif">All you need to do is open the parameter pill and select Show Parameter Control</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX9_Fb_D2wFSNOM19WUlnosxLSZqfhAiR6xU9ZLbrNVu3op0GFbcZQmdO05v0ZfXMIU_ONPjh1TeFdFFnVj0qRzqki6HdeE_POmoCmkkDe03y_nuAE5QYV8I-IuNK54buB_k2CJ5KBdHA/s1600/show+param+control.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="250" data-original-width="597" height="167" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX9_Fb_D2wFSNOM19WUlnosxLSZqfhAiR6xU9ZLbrNVu3op0GFbcZQmdO05v0ZfXMIU_ONPjh1TeFdFFnVj0qRzqki6HdeE_POmoCmkkDe03y_nuAE5QYV8I-IuNK54buB_k2CJ5KBdHA/s400/show+param+control.PNG" width="400" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /><br /><b><br /></b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><b>3-Use it in a calculation or a filter</b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span><span face=""arial" , "helvetica" , sans-serif">After creating the parameter you need to use it - it is the calculation or the filter that affects the data in the viz - not the parameter by itself. </span><br />
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span><span face=""arial" , "helvetica" , sans-serif"><b>Example 1 - Parameter driven T/F filter</b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span><span face=""arial" , "helvetica" , sans-serif">The easiest way to use the parameter is in a True/False filter - the expression just says when the subcategory is equal to the one the user selected using the parameter return a True</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQvy8rgJmUJhS03FQeXrKRF93l453HkEwu01vXVKdeYaaDYUYpNpizPiot6eVlUZz3UcBXywvlOgnwuipKXpdmOesmu3iNyFV-Jnz0aly1UdVLgGKyRYtDjkkGq-OMeiWSSh4SwDR0OVE/s1600/tf+filter.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="145" data-original-width="448" height="128" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQvy8rgJmUJhS03FQeXrKRF93l453HkEwu01vXVKdeYaaDYUYpNpizPiot6eVlUZz3UcBXywvlOgnwuipKXpdmOesmu3iNyFV-Jnz0aly1UdVLgGKyRYtDjkkGq-OMeiWSSh4SwDR0OVE/s400/tf+filter.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">Placed on the filter shelf and set to True will return this</span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEillHTHyLUVthstvjcsy9ZWtzYOne5zZNPjcawy_VyCeBwtkMnJZXsoGD6iwtUfDQZoDAz3Mh3OiZxH0Rz6k1cKIu7_8KhD1tYQG008BSG21EUismEtiIiGNF_Cy8Skt9WXXLMk_-qdKKM/s1600/tf+filter+pnoe+example.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEillHTHyLUVthstvjcsy9ZWtzYOne5zZNPjcawy_VyCeBwtkMnJZXsoGD6iwtUfDQZoDAz3Mh3OiZxH0Rz6k1cKIu7_8KhD1tYQG008BSG21EUismEtiIiGNF_Cy8Skt9WXXLMk_-qdKKM/s640/tf+filter+pnoe+example.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><b>Example 2 - Use it in a Set</b></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">The same parameter can be used to create a set - The Formula area on the Condition tab acts like an LOD -aggregate the dimension using Max or Min (sorry no Attr()) - set the </span><span face=""arial" , "helvetica" , sans-serif">Max subcategory to the parameter value to select the "In" value - all others are in the "Out"</span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEiT6kpv7mgmc5qO8WnKwJwgk9zaHP3CHtl4ByYXf_t64iRJHM_2sFvFVimh_vWfoSrsQQoCCAaCKFOzX_uqUma9CUC2KYc9lqViVvTPBH1NrpyFITt3GHzLVkJ-6T7hpxeqnHaYIMtbM/s1600/crete+set+from+param.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEiT6kpv7mgmc5qO8WnKwJwgk9zaHP3CHtl4ByYXf_t64iRJHM_2sFvFVimh_vWfoSrsQQoCCAaCKFOzX_uqUma9CUC2KYc9lqViVvTPBH1NrpyFITt3GHzLVkJ-6T7hpxeqnHaYIMtbM/s640/crete+set+from+param.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">a possible viz could compare the selected subcategory to all others</span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi06RfQC_xKlDbNoIvlcNnb9piI-LtRuIYwxME32lV_TUp7wDmVDOdqaeffhwbKg4Q39-qF52Q-r4h5AWq0DrAvPwctQ3KccXmmLPwfp2S3XVs3SftsgJ9sC1CaZZJlVmirXxODxX4E1gk/s1600/in+out+set+from+param.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi06RfQC_xKlDbNoIvlcNnb9piI-LtRuIYwxME32lV_TUp7wDmVDOdqaeffhwbKg4Q39-qF52Q-r4h5AWq0DrAvPwctQ3KccXmmLPwfp2S3XVs3SftsgJ9sC1CaZZJlVmirXxODxX4E1gk/s320/in+out+set+from+param.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><b>Example 3 - Change all views in a dashboard</b></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">Parameters are global - when the value is changed it changes all the calculations or filters where the parameter is used -</span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">Bring the 2 worksheets together on a dashboard and changing the parameter value will affect both sheets without using filters or actions</span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"></span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: center;">
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><b>Example 4 Top N filtering</b></span></div>
</div>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif">Parameters can also take on numeric values like in the following Top N example </span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif">Create a filter on Subcategory and open the Top tab </span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif">Select Create From Parameter</span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmCt2didq9sxfg5-XPYSldKBlo5VhtGLvEX-1oca2lEHVOSd8n5ohz40oxvKZXLl6J4g-uusAA7ecpoucyR9vD-sX1tIHlhYTiHJi7TW7Afyh2ObQhB4rf8mAF7ve17Bb1ZDFuDtvfAMg/s1600/new+create+top+n.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmCt2didq9sxfg5-XPYSldKBlo5VhtGLvEX-1oca2lEHVOSd8n5ohz40oxvKZXLl6J4g-uusAA7ecpoucyR9vD-sX1tIHlhYTiHJi7TW7Afyh2ObQhB4rf8mAF7ve17Bb1ZDFuDtvfAMg/s640/new+create+top+n.png" width="640" /></a></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">When the window opens - select a starting value and a range</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-hbwg-tdnGsiaMc95nhCtKzQJkGHuLF2ZFMCPaS_ycMSXNRV9PvBJwRUfcxrPKI1OQvPARgw467AmbF31eJwtmgGwUuVNr5otBMoMiix8IZJQUo7mJVKbGBIH4oEDg1aV3iYMhxy_hBE/s1600/set+up+top+N+param+value.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="405" data-original-width="560" height="288" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-hbwg-tdnGsiaMc95nhCtKzQJkGHuLF2ZFMCPaS_ycMSXNRV9PvBJwRUfcxrPKI1OQvPARgw467AmbF31eJwtmgGwUuVNr5otBMoMiix8IZJQUo7mJVKbGBIH4oEDg1aV3iYMhxy_hBE/s400/set+up+top+N+param+value.PNG" width="400" /></a></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">and create a viz </span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKy9VqG9Fxjd0Whn89KIw4ZY4oTtpYWA_Co-EE0qNiOYBA8ZUX-RyNVqA6pIZ3c_BYGNX69fLPphzzC5g3IQOu4toEFV12-W_Y9pF_ZB_qSUTOHScNBYeqhuwv6aM_RdrdgdAeLt4FXoU/s1600/Top+N+output.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKy9VqG9Fxjd0Whn89KIw4ZY4oTtpYWA_Co-EE0qNiOYBA8ZUX-RyNVqA6pIZ3c_BYGNX69fLPphzzC5g3IQOu4toEFV12-W_Y9pF_ZB_qSUTOHScNBYeqhuwv6aM_RdrdgdAeLt4FXoU/s640/Top+N+output.png" width="640" /></a></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif">The user can set the N from the control on the left - Note also the subcategory drop down will list all subcategories and has a reference to the Top N filter application </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><b>Example 5 - Parameter Actions</b></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif">With the 2019.2 release Parameter Actions were introduced given the user an easy visual way to change parameter values for the viz without opening a drop down - </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">I will replace the parameter drop down from the earlier example with a value picker - a simple worksheet with the values (here subcategory names and a circle mark) A horizontal will work well the the overall layout of the dashboard</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVL8Ymd9ofakmGEVRWJ08uskn93Qef_XVKq61oHSn3P3ZF-4Q7cp3LNcIgLHB7contadmiOEK8aa3PdIHqAoKvah4TJACHIncHMcUW_nt3Z8WMiFbp6Gsn51rJyfSA11RmPIesg8Na-1w/s1600/value+picker.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="186" data-original-width="1596" height="74" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVL8Ymd9ofakmGEVRWJ08uskn93Qef_XVKq61oHSn3P3ZF-4Q7cp3LNcIgLHB7contadmiOEK8aa3PdIHqAoKvah4TJACHIncHMcUW_nt3Z8WMiFbp6Gsn51rJyfSA11RmPIesg8Na-1w/s640/value+picker.PNG" width="640" /></a></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">Add the value picker to the dashboard and create a Parameter Action -</span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
</div>
<ul>
<li><span face=""arial" , "helvetica" , sans-serif">From the Dashboard on the upper ribbon select Action</span></li>
<li><span face=""arial" , "helvetica" , sans-serif">Then Add - Change Parameter</span></li>
<li><span face=""arial" , "helvetica" , sans-serif">Give the action a name</span></li>
<li><span face=""arial" , "helvetica" , sans-serif">The source is - Value Picker </span></li>
<li><span face=""arial" , "helvetica" , sans-serif">The target is Select Subcategory parameter</span></li>
</ul>
<br />
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">I used Hover for the example you can select what works best in your analysis</span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUlWPQ2FkixVPBxDb-Gl-wtnhbPuRy7KZnYd9jjzloFs78LcAbHB1eb_rKAHO4n_JDvNnO_K_B7osg-N95FwYnmp4a2CGVTRc6nCNUleACZFPjlAAvk_gNR0JOne1b_1__YSzLXTEiAvQ/s1600/create+param+action.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUlWPQ2FkixVPBxDb-Gl-wtnhbPuRy7KZnYd9jjzloFs78LcAbHB1eb_rKAHO4n_JDvNnO_K_B7osg-N95FwYnmp4a2CGVTRc6nCNUleACZFPjlAAvk_gNR0JOne1b_1__YSzLXTEiAvQ/s640/create+param+action.png" width="640" /></a></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif">The value of the parameter and the viz will change as the user hovers order the Value Picker marks - see the video</span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">Have some fun with Parameter Actions -They are major enhancement for the user experience</span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><b>Example 6 Dynamic Parameters</b></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">Now the game changer - Dynamic Parameters - introduced with the 2020.1 release the parameter value list can be updated when the date source is updated and the workbook is opened - see how they work in the simple example below</span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">In this example sales data is updated weekly - the initial load includes 4 dates 4/13-18 - the user wants to use a parameter to filter by individual date - the viz looks something like this:</span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0mRsm0AmY6m9Iv1_mT5DNZxM8lS8fRYbyV_do6WtBx983LBZ922h29jm8R4BFPjRF_boYlL-U2vG7gm7XLfZD2zGTa4IwcWgdvitoBwvdx__9u1dV_Q6Z-WHJ9v0oVy8bvqUieh7N7dk/s1600/dyn+parm+start.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0mRsm0AmY6m9Iv1_mT5DNZxM8lS8fRYbyV_do6WtBx983LBZ922h29jm8R4BFPjRF_boYlL-U2vG7gm7XLfZD2zGTa4IwcWgdvitoBwvdx__9u1dV_Q6Z-WHJ9v0oVy8bvqUieh7N7dk/s640/dyn+parm+start.png" width="640" /></a></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif">The dynamic parameter set up adds only a couple fields to the one you have used so far</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<br />
<ul>
<li><span face=""arial" , "helvetica" , sans-serif">the parameter that is to be updated and </span><span face=""arial" , "helvetica" , sans-serif">the field in the data set</span></li>
<li><span face=""arial" , "helvetica" , sans-serif">initial value of the parameter (default is Current) </span></li>
</ul>
<br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">In the example I added an LOD for the fixed max date in the data set - the parameter value will update to the latest date in the data set</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCO8Zy3c1g_J0IKCFbtp4raUgNOkSOklgs2dBluSlxxgvhYo3j8r4oK3Lyr3OwX-c5u0uftGCl_1zxKg71hQNzkypblWuER1QRewNz3auSd6mBHC-5nj1TVKuJIbB2aH9jhYPUUQ4Z2u4/s1600/dyn+param+setup.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCO8Zy3c1g_J0IKCFbtp4raUgNOkSOklgs2dBluSlxxgvhYo3j8r4oK3Lyr3OwX-c5u0uftGCl_1zxKg71hQNzkypblWuER1QRewNz3auSd6mBHC-5nj1TVKuJIbB2aH9jhYPUUQ4Z2u4/s640/dyn+param+setup.png" width="640" /></a></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif">When you update the data and when you reopen the book the parameter updates</span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiznVNzT1d5SFBMxdmtDtoRUR-sQ6oDwPDnpS1qy7Kz0mFHBguN2TY6gXaZnABhvhA8KTKpjljnx_stIHUgnXvYPdl9Zadu8uSjYaDBVD638bv_-0XJjkLaxHgncHQD6txxpxt5JaxNVo/s1600/dyn+paramter+updated+view.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiznVNzT1d5SFBMxdmtDtoRUR-sQ6oDwPDnpS1qy7Kz0mFHBguN2TY6gXaZnABhvhA8KTKpjljnx_stIHUgnXvYPdl9Zadu8uSjYaDBVD638bv_-0XJjkLaxHgncHQD6txxpxt5JaxNVo/s640/dyn+paramter+updated+view.png" width="640" /></a></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;"><span face=""arial" , "helvetica" , sans-serif"><br /></span></div><div style="text-align: left;"><span face=""arial" , "helvetica" , sans-serif"><b style="font-family: arial;">NOTE - UPDATE the 2020.3 release now will update the parameter and from a data source refresh or edit - If you are on an earlier version see below</b></span></div><div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Desktop users - Note if working from a live data source and manually refresh the source you will need to close and reopen the Tableau workbook before the parameter updates</span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif">I hope this helps you understand parameters, parameter actions and dynamic parameters better - I love using them - with a little practice you can too</span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif">The workbook examples used in the first part of this post can be found on my Tableau Public site at </span><a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/parameterworkbook/ValuePickerdrivendb?publish=yes">https://public.tableau.com/profile/jim.dehner#!/vizhome/parameterworkbook/ValuePickerdrivendb?publish=yes</a></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif">Enjoy</span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif">Jim</span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
</div>
</div>
www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-66853154948111813362020-02-10T17:29:00.002-06:002020-02-10T17:29:17.082-06:00Dates Functions and Other Necessary Evils<h2>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Dates Functions and Other Necessary Evils</span></h2>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I've had my "issues" with dates - maybe you have too - Date functions allow us to make spectacular charts, compare period sales and track trends over time. But which one do you use and when?</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Dates are a very special class of dimensions - they self sequence, have a built-in hierarchy, can be used as discrete or continuous dimensions, adjust to your fiscal year start and can be customized - pretty cool - but the flexibility leads to confusion. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">This post will explore Date Functions - Formats and Custom Dates will be review in a future article </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Starting at the beginning - dates can take on 2 different forms - </span><br />
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Date Parts categorize data and are discrete - bar charts, period analysis</span></li>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Date values are a continuous form - make great line charts, trending </span></li>
</ul>
<div>
<b><span style="font-family: "arial" , "helvetica" , sans-serif;">Date Part</span></b></div>
<div>
<b><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></b></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Dates in Tableau have a built in hierarchy that begin with Year and ends with Seconds</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-VYBgflDoW8gB4h1sIZhg93fPqKzsMyWmBUGPRN4AG9850SPACK5xiCA41UrRm_F3H7pf2K6ffzjr2pyiapCf7c__zMrVjcxQJ7nu32JYIO53d2bmc2fd46YzkN9bjnJNIr5KlMGGNas/s1600/grey+chevrons.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="188" data-original-width="1200" height="100" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-VYBgflDoW8gB4h1sIZhg93fPqKzsMyWmBUGPRN4AG9850SPACK5xiCA41UrRm_F3H7pf2K6ffzjr2pyiapCf7c__zMrVjcxQJ7nu32JYIO53d2bmc2fd46YzkN9bjnJNIr5KlMGGNas/s640/grey+chevrons.PNG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div>
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The various Date part functions have a similar format and truncate the date at the level selected</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">- using date part as an example - here the date dimension Start Date is truncated at Year</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The format for the level selected is always singular and is enclosed in single quote marks</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Datepart('year',[start date])</b></span></div>
<div style="text-align: center;">
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">It may be easier to see what the various levels will return from the chart below</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Note the values returned using Datepart function are Integers - also note that Hour is based on a 24 hour clock </span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIbTyEVcsOjbyYuYZ46vd3hQsWu_aqqapOqRC-qQYfngDN73qVPCFKEXN2a34NUo7fGFJp-dk3azcOIVIygLsMhEaC99RZps4Ou53qAFsGpQT6tb1DI7l6OONRstQD0nQCiJaSwfLy2W4/s1600/datepart+examples.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="191" data-original-width="1005" height="120" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIbTyEVcsOjbyYuYZ46vd3hQsWu_aqqapOqRC-qQYfngDN73qVPCFKEXN2a34NUo7fGFJp-dk3azcOIVIygLsMhEaC99RZps4Ou53qAFsGpQT6tb1DI7l6OONRstQD0nQCiJaSwfLy2W4/s640/datepart+examples.PNG" width="640" /></a></div>
<div>
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">There are also some date levels that are not part of the date hierarchy that are useful as you will see later </span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirwmza_dbTW-b3uIzadceyWVKOa26rtydhmENYKp46QKE_cXYBNwyvxyPXGQaAVE8q_fQT4OS7ZW-8kieM_PF70OZ-Q1U66TeK2d5wiCz6P01h7WTgCDtWtMDNIrnMCYei_TgAyFKwlaQ/s1600/grey+week+week+day+day+of+year.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="237" data-original-width="986" height="95" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirwmza_dbTW-b3uIzadceyWVKOa26rtydhmENYKp46QKE_cXYBNwyvxyPXGQaAVE8q_fQT4OS7ZW-8kieM_PF70OZ-Q1U66TeK2d5wiCz6P01h7WTgCDtWtMDNIrnMCYei_TgAyFKwlaQ/s400/grey+week+week+day+day+of+year.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Alternately you could use </span><b style="font-family: arial, helvetica, sans-serif;">Datename </b><span style="font-family: "arial" , "helvetica" , sans-serif;">- returns the actual string (text) value of the level - January, Wednesday</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr9M4GPSgY-KcS5K9XJpYGtKMXEyEywzBLamBAbdVYKEXCoxFyct2N6k8N4hhQtdxTTkWAr9e1l3XJh_nnO4o1plAMWE-97nL_9gkQEE18Z0HJImZcSQazE3MLmJxYTl9awT9a_XCEvyA/s1600/daatename+chart.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="232" data-original-width="1466" height="100" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr9M4GPSgY-KcS5K9XJpYGtKMXEyEywzBLamBAbdVYKEXCoxFyct2N6k8N4hhQtdxTTkWAr9e1l3XJh_nnO4o1plAMWE-97nL_9gkQEE18Z0HJImZcSQazE3MLmJxYTl9awT9a_XCEvyA/s640/daatename+chart.PNG" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">For all the examples I will use the Superstore dataset that came with your copy of Tableau - you will be able to re-create examples</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<b style="font-family: arial, helvetica, sans-serif;">1 - Use Datepart to show Monthly sales</b></div>
<div>
<b style="font-family: arial, helvetica, sans-serif;"><br /></b></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Start with a simple date function which truncates the date at the month level</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>DATENAME('month', [Order Date])</b></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Create a viz using datename on columns and sum(sales) on rows</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRQSla4_LuihLUAaEAPLwjUCdZuPy7aap44i1nr_W4xN9vAXH5pIsNHCqgsTsG4iFuYfqC1iLNX9P81R7UctfZhOljdDzgjA5GbDSCFIs7xmIoWMX9BUJKHTYMi-dgoJ8-wgCcLtqOWGU/s1600/sales+by+month.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="919" data-original-width="1079" height="272" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRQSla4_LuihLUAaEAPLwjUCdZuPy7aap44i1nr_W4xN9vAXH5pIsNHCqgsTsG4iFuYfqC1iLNX9P81R7UctfZhOljdDzgjA5GbDSCFIs7xmIoWMX9BUJKHTYMi-dgoJ8-wgCcLtqOWGU/s320/sales+by+month.PNG" width="320" /></a></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Datename is a discrete function that defaults to a bar chart - a discrete chart type - the bars present to total sales by month for all dates in the data set - </span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">You could create the same chart simply by dragging the Order date to columns and set the level to month- When you do Tableau will default to a line chart - same numerical data just a continuous chart type - </span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm9EA42KFOCWJE9eYD6Ivn8B6_oVrAkX_ri441N_TGH4qli9h-EPVMOlA-sJJ8aDAwYBdvVZaJj7dAfoCGm52Xy_EAOo43u08TI5B-gtAGPm1Xv-ZEw7I2zckWNJR-oTWy14UJeAfgy8c/s1600/sales+by+month+as+line.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="908" data-original-width="885" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm9EA42KFOCWJE9eYD6Ivn8B6_oVrAkX_ri441N_TGH4qli9h-EPVMOlA-sJJ8aDAwYBdvVZaJj7dAfoCGm52Xy_EAOo43u08TI5B-gtAGPm1Xv-ZEw7I2zckWNJR-oTWy14UJeAfgy8c/s320/sales+by+month+as+line.PNG" width="311" /></a></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">That's one of the confusing issues with dates - sometimes they default to discrete types and at others to continuous - easy enough to change in this example by changing the chart type to Bar - </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>2 Year Month - When to use discrete chart types</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">If we add Year of order date you can begin to see where discrete chart types better represent the data </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">This will place the Year for reach record (row) in the data </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<div style="text-align: center;">
<b><span style="font-family: "arial" , "helvetica" , sans-serif;">DATENAME('year',[Order Date])</span></b></div>
</div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
</div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">When applied to the previous month it is easy to see the progression of sales over the years and months</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFAaJfeyC3D5xkDxA0YJbDiDu2F3rMUbqDWS31xz18DAfLYX6AHdOqP1jrcRwq26WjzNo9iymW_2y2ibX0MSFWGsXJYdgl_eu8JvFmfa_m1c8cxUV4rffD3VGSM5G3PicuDqTiyMmdZ_8/s1600/discrete+ym+sales.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="903" data-original-width="1353" height="425" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFAaJfeyC3D5xkDxA0YJbDiDu2F3rMUbqDWS31xz18DAfLYX6AHdOqP1jrcRwq26WjzNo9iymW_2y2ibX0MSFWGsXJYdgl_eu8JvFmfa_m1c8cxUV4rffD3VGSM5G3PicuDqTiyMmdZ_8/s640/discrete+ym+sales.PNG" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Adding year to the continuous chart also shows the progression but there is a discontinuity at the first of every year</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT9CkdwssDazwWs6HmSC5_QrpOWyJ_m0FnQ6F988nQAgkdZKmgqA-L9zZw6p78wlxCyOGQUL4VayIlTEd1R6O_lDpDTAK66upShxO9rdbZg-lRQb7SCStkcTfa5iqjIFFhbrkeIeMkJn8/s1600/continuous+ym.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="927" data-original-width="1257" height="468" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT9CkdwssDazwWs6HmSC5_QrpOWyJ_m0FnQ6F988nQAgkdZKmgqA-L9zZw6p78wlxCyOGQUL4VayIlTEd1R6O_lDpDTAK66upShxO9rdbZg-lRQb7SCStkcTfa5iqjIFFhbrkeIeMkJn8/s640/continuous+ym.PNG" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">The data are the same - the discrete date part calculation categorize data into year/month buckets - the bar chart (discrete) height represents to total for the month</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">The continuous chart type also present the monthly total but only the the marks at the month points are an accurate representation of the sales - the lines between just connect the marks and do not relate to sales on any day</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>3 YTD and YOY with Date Parts</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Using <b style="text-align: center;">DATEPART</b> is one way to do a YTD and prior year to date analysis</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Current Year Sales can be calculated as</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>if DATEPART('dayofyear',[Order Date])<=datepart('dayofyear',today())</b></span></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>and DATEPART('year',[Order Date])=datepart('year',today())</b></span></div>
<div style="text-align: center;">
<b><span style="font-family: "arial" , "helvetica" , sans-serif;"></span></b></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>then [Sales] else NULL end</b></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Prior Year Sales as</span></div>
<div style="text-align: left;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>if DATEPART('dayofyear',[Order Date])<=datepart('dayofyear',today())</b></span></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>and DATEPART('year',[Order Date])=datepart('year',today())-1</b></span></div>
<div style="text-align: center;">
<b><span style="font-family: "arial" , "helvetica" , sans-serif;"></span></b></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>then [Sales] else NULL end</b></span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">then they can be presented in side by side charts as </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIeWBhLgP9_w8xHd1JD4UOXnaWh-tcPrK58vHzBxljeHuv03xxoq01FO_Fb8BB0zBs-iDU0ice3yqbee1UavL-ips0qAyDUA9Yu6nofFIYfqAIhrfVQYu5dGoV6C6ZpNbcooC906REBAI/s1600/cy+py+ytd.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="898" data-original-width="717" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIeWBhLgP9_w8xHd1JD4UOXnaWh-tcPrK58vHzBxljeHuv03xxoq01FO_Fb8BB0zBs-iDU0ice3yqbee1UavL-ips0qAyDUA9Yu6nofFIYfqAIhrfVQYu5dGoV6C6ZpNbcooC906REBAI/s320/cy+py+ytd.PNG" width="255" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>4 Day of Week Sales Heat Map</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">With the Week and Weekday options you could look at the how sales vary by day of the week over the 53 week year</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The day of the week for each record is </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>DATENAME('weekday',[Order Date])</b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">and the week number can be determined datepart</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>datepart('week',[Order Date])</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnRVSBUY_7hDXFspIc6S6WmcQhyphenhyphenq-R8m6g24CFEsdMZnAVz4CGa3FOetzl-Sh9piTsC_a80ELSMM-og5K0j6D8ptBV8wJTbZAFdSsfUcEY4Xqt0ixA0FDHh5JKGe5Mft3swW4FSCpDqH4/s1600/weekday+sales.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="488" data-original-width="1600" height="194" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnRVSBUY_7hDXFspIc6S6WmcQhyphenhyphenq-R8m6g24CFEsdMZnAVz4CGa3FOetzl-Sh9piTsC_a80ELSMM-og5K0j6D8ptBV8wJTbZAFdSsfUcEY4Xqt0ixA0FDHh5JKGe5Mft3swW4FSCpDqH4/s640/weekday+sales.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>5 Days to Ship</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">A common metric for manufacturers is Days to Ship - here we will use it to illustrate a point about knowing the data elements in the data set</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The function used is Datediff - it takes the difference in days (the date level) between the order and the ship date </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>DATEDIFF('day',[Order Date],[Ship Date])</b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The function works at the row level - in the Superstore data set the data is kept at the product level - equivalent to row level data on the invoice - and orders may have several products</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The measure the shipping department wants to be measured on is on the order level - the LOD below will return the days to ship for the order </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>{ INCLUDE [Order ID]:AVG(DATEDIFF('day',[Order Date],[Ship Date])) }</b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj21DW43X96aDTjcdH9dUniz3zPgz0HBo759vnZhsqZHRvhq5RVolD98FAkwX6dQzE5YJi7Lls7HrCFS8b2tBHFduxG-psWV-aYZpiHQUT_N9aCKZe49y5qAWan33BxPH7JX7zr91IeUxw/s1600/days+diff.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="352" data-original-width="834" height="270" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj21DW43X96aDTjcdH9dUniz3zPgz0HBo759vnZhsqZHRvhq5RVolD98FAkwX6dQzE5YJi7Lls7HrCFS8b2tBHFduxG-psWV-aYZpiHQUT_N9aCKZe49y5qAWan33BxPH7JX7zr91IeUxw/s640/days+diff.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">May not see like a lot - but if the metric is a department KPI it will be noticed</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">And you could come up with many more examples - remember that date part functions create dimensions that categorize the data at the row level and can be used like any other dimension in charts, graphs, calculations or filters</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Date Values</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Alternative date function formula can return a continuous value - </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">If you are familiar with the date value and time value formulas in excel the concept is the same. Date values increment daily time values are decimal parts of a day. (Caution the starting point for Tableau and Excel are not the same so the actual values vary by a couple days)</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The same array of levels are available for date values but the functions returns the first value in the level as a real date - an example will be clearer - using the same date chart as before</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">At each level the datetrunc formula will take the form of </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>datetrunc('year',[Start Date])</b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Datetrunc will return the starting value of the selected level of the date hierarchy as a value out to the second </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Review the chart below and see how it differs for the earlier date part version of the same dates - </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVRFBTK5d0JlHxSEQShKgddbp_QliA4D6YWuF_pxFzwA4Cjv8f4PLC870D6PyHwij2c2rP-U4tPDj0nJhjSjms81FbpmI52nCMUZYxcarBUo9Czvh1wT0SAib9fsancp-Fqhf6J8nk7Go/s1600/datetrunc+parts.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="210" data-original-width="1422" height="94" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVRFBTK5d0JlHxSEQShKgddbp_QliA4D6YWuF_pxFzwA4Cjv8f4PLC870D6PyHwij2c2rP-U4tPDj0nJhjSjms81FbpmI52nCMUZYxcarBUo9Czvh1wT0SAib9fsancp-Fqhf6J8nk7Go/s640/datetrunc+parts.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Clearly the values are different - </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>6 YTD using Datetrunc</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">This formula will return all records in the current year </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>if DATETRUNC('year',[Order Date])=DATETRUNC('year',today()) then [Sales] end</b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The date level to display can be set by selection from the drop down list</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQvDABBKgsV9KR9EZ9wGO9Ztemnh_qcyUxbW2PTcGkD-fDwhHCc-BPjcdxF_Ou4BKJrxJAY2_7mQ_dCjvVtuO2aDbLeuPETMck3P8Cry06hEtdiR0SHK3Cbk08yPf27MNhLXg4aRyrvwA/s1600/continuous+level+selection.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQvDABBKgsV9KR9EZ9wGO9Ztemnh_qcyUxbW2PTcGkD-fDwhHCc-BPjcdxF_Ou4BKJrxJAY2_7mQ_dCjvVtuO2aDbLeuPETMck3P8Cry06hEtdiR0SHK3Cbk08yPf27MNhLXg4aRyrvwA/s640/continuous+level+selection.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">And the data are plotted as a continuous line for each day of the current year - </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_tgSbJh1LsHPtrkEZn67r8rVqPh_ZLlJnCGs4M1ZxB1w_B3AL_-MxUjJ7yKpOJHjoOdfI8OhwEUMEt9B43g18fOQzEhudUCGdnrKuA3Jyso5miLf9PFs5u1PcoXRpZ4M5_NYZAcaOqas/s1600/contiunous+line+chart.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="856" data-original-width="1600" height="342" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_tgSbJh1LsHPtrkEZn67r8rVqPh_ZLlJnCGs4M1ZxB1w_B3AL_-MxUjJ7yKpOJHjoOdfI8OhwEUMEt9B43g18fOQzEhudUCGdnrKuA3Jyso5miLf9PFs5u1PcoXRpZ4M5_NYZAcaOqas/s640/contiunous+line+chart.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now change the formula to include all prior years </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<div style="text-align: center;">
<b style="font-family: arial, helvetica, sans-serif;">if DATETRUNC('year',[Order Date])<span style="color: red;"><=</span>DATETRUNC('year',today()) then [Sales] end</b></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">and at the day level the chart becomes</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuruULPK4S31skYZLH6_iDpT0R-yAUNT91zbnhBJl8k11B91IGjA_w2EDogx1X95wrrTnxzGwxLJfwW-ACY98vsVNrSM9CuBC7hGN0eIXLxh3EnT3YRBUEgNNU-vtHclXWOVXE8k0VdIc/s1600/all+prior+dates.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="889" data-original-width="1543" height="368" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuruULPK4S31skYZLH6_iDpT0R-yAUNT91zbnhBJl8k11B91IGjA_w2EDogx1X95wrrTnxzGwxLJfwW-ACY98vsVNrSM9CuBC7hGN0eIXLxh3EnT3YRBUEgNNU-vtHclXWOVXE8k0VdIc/s640/all+prior+dates.PNG" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">It may be too busy to be practical but easily changed to months</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR7O-FmTCXOsLDNV8oh-_IiF5mvll52ENJP7TK2nGp3V829JgdUcepBJcuVauXaxWfj0OXczlVOUhTBCwANPxU1jo4BvvIvAXHyVj7iZivBbcxFMo4Olk2JETQAR3ZhBL-awqShGekC8k/s1600/all+dates+months.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="911" data-original-width="1557" height="374" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR7O-FmTCXOsLDNV8oh-_IiF5mvll52ENJP7TK2nGp3V829JgdUcepBJcuVauXaxWfj0OXczlVOUhTBCwANPxU1jo4BvvIvAXHyVj7iZivBbcxFMo4Olk2JETQAR3ZhBL-awqShGekC8k/s640/all+dates+months.PNG" width="640" /></a></div>
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Note there are no breaks at the end of each year as there were with the discrete data part function - one of the advantages of using a continuous function</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>7 Trend lines</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Trend lines can be added to any continuous graph directly from the Analytics tab </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Place the continuous month on columns and the measure on rows - then just drag the trend line to the canvas</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQwnJMAvt9_N6Dz98SGWdXgIwH5cEAxoII4H7mx9Thjttv4297ANfmpKGx21yecOgdtCKIZzxBA-ct__OjNuxNbQJKSFjLeA1PrLWDRtCiERQ0XNY0P803BefdK2n1NdfBtSajWV9XDwo/s1600/trend+line.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQwnJMAvt9_N6Dz98SGWdXgIwH5cEAxoII4H7mx9Thjttv4297ANfmpKGx21yecOgdtCKIZzxBA-ct__OjNuxNbQJKSFjLeA1PrLWDRtCiERQ0XNY0P803BefdK2n1NdfBtSajWV9XDwo/s640/trend+line.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>8 Parameter Driven Continuous Line Charts</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;">A poster to the Forum brought a particularly interesting challenge recently - they wanted a continuous chart that was driven by a parameter to select the level of the date and a second parameter to set the number of periods in the chart</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">The solution combines several of the concepts discussed</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">First create a parameter to change the date level from days - years</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1k8ATnVNZabvf7TYXlSloLN1l3Jmr4v9NS283h8-HTVHrU7wA66ZF4ShnoBjNly1scBcxsKDs9AIsJNB3PWVE1uvEfiqyX5IgXFvsFdUeuirgGzw5pir1_zf6ZlG9HRwFsTljOxkE-gc/s1600/date+level+param.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="491" data-original-width="559" height="351" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1k8ATnVNZabvf7TYXlSloLN1l3Jmr4v9NS283h8-HTVHrU7wA66ZF4ShnoBjNly1scBcxsKDs9AIsJNB3PWVE1uvEfiqyX5IgXFvsFdUeuirgGzw5pir1_zf6ZlG9HRwFsTljOxkE-gc/s400/date+level+param.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">And a second parameter to allow the user to select how many periods to include in the chart</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOCoRVgx4ldHpsjit1fWbv9Hn754KHapsKqHUJr7aNWEFWsB2RkA5JeV9EgCO-kExuOJ7LKn-HF_Wl3MM2kd3-9birBBrhGS_r_BwwjnCH7tzwtUISWCmNmfLMyswqZyMfZIp2f0D0fvs/s1600/look+back+param.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="252" data-original-width="565" height="177" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOCoRVgx4ldHpsjit1fWbv9Hn754KHapsKqHUJr7aNWEFWsB2RkA5JeV9EgCO-kExuOJ7LKn-HF_Wl3MM2kd3-9birBBrhGS_r_BwwjnCH7tzwtUISWCmNmfLMyswqZyMfZIp2f0D0fvs/s400/look+back+param.PNG" width="400" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Next create a dimension based on the parameter that will be used as the continuous date axis in the chart </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Case for dimension;</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>date( CASE [Date level] </b></span></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>when "Day" then datetrunc('day',[Order Date])</b></span></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>when "Month" then datetrunc('month',[Order Date])</b></span></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>when "Week" then datetrunc('week',[Order Date])</b></span></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>when "Year" then datetrunc('year',[Order Date]) </b></span><b style="font-family: arial, helvetica, sans-serif;">end )</b></div>
<div style="text-align: center;">
<b style="font-family: arial, helvetica, sans-serif;"><br /></b></div>
<div style="text-align: center;">
<b style="font-family: arial, helvetica, sans-serif;"><br /></b></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The statement might look intimidating but all is really does is use the Datetrunc function to create an axis for the chart at the level selected in the Date Level parameter. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">And finally a filter to determine which data to include </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Parameter Drive Filter:</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b> CASE [Date level]</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>When "Day" then datetrunc('day',( min([Order Date (Days)])))>=datetrunc('day',dateadd('day',-[lookback period],today()))</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>and DATETRUNC('day', min([Order Date (Days)]))<=datetrunc('day',today())</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>when "Month" then datetrunc('month',( min([Order Date (Days)])))>=datetrunc('month',dateadd('month',-[lookback period],today()))</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>and DATETRUNC('month', min([Order Date (Days)]))<=datetrunc('month',today())</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>when "Week" then datetrunc('week',( min([Order Date (Days)])))>=datetrunc('week',dateadd('week',-[lookback period],today()))</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>and DATETRUNC('week', min([Order Date (Days)]))<=datetrunc('week',today())</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>when "Year" then datetrunc('year',( min([Order Date (Days)])))>=datetrunc('year',dateadd('year',-[lookback period],today()))</b></span><br />
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>and DATETRUNC('year', min([Order Date (Days)]))<=datetrunc('year',today()) end</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Now that one is messy - but there are 4 similar segments each looks at a different date level and decides of the order date is within the lookback period the user wants to see - Once again using the continuous Datetrunc function</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Then it is just a matter of placing everything on the viz</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgs8hbieLS2ZVlRw7YQ7j6M8fKSZhsMwQTT4gGTUSf-d4WVwFVIUhodYoB5mP_L4axUEbCReQcnEYA7gqMJPBYf3QyzN5rAQzh8je8Sm50223bVSzwtFNRMpU1LNmg5cogqxD0XpmfWtG8/s1600/dynamic+parameter+driven.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgs8hbieLS2ZVlRw7YQ7j6M8fKSZhsMwQTT4gGTUSf-d4WVwFVIUhodYoB5mP_L4axUEbCReQcnEYA7gqMJPBYf3QyzN5rAQzh8je8Sm50223bVSzwtFNRMpU1LNmg5cogqxD0XpmfWtG8/s640/dynamic+parameter+driven.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">and the user can now dynamically change date levels and period from the 2 parameters </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-GkGQcYTxn4lYtb-WltSCM8bOMM028SI9NpoYwvsqh-PtQ-DbS_im37YQGzJ5BeAajgerykCBljXvhNbLlMDRlAPEuDaz_C3l9DcRSTt6v_v9HBOxji5X7tJXb9RUM_1TOn5OETigJF4/s1600/week+w+12+periods.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="905" data-original-width="1139" height="508" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-GkGQcYTxn4lYtb-WltSCM8bOMM028SI9NpoYwvsqh-PtQ-DbS_im37YQGzJ5BeAajgerykCBljXvhNbLlMDRlAPEuDaz_C3l9DcRSTt6v_v9HBOxji5X7tJXb9RUM_1TOn5OETigJF4/s640/week+w+12+periods.PNG" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">There can by many more examples but the best way to learn about date functions is to use them - </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">A workbook containing the examples shown here can be found at :</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/DateFunctionExamples/SalesbyMonth">https://public.tableau.com/profile/jim.dehner#!/vizhome/DateFunctionExamples/SalesbyMonth</a></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Feel free to download it and use it a template</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Enjoy</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Jim</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Next: Date Formats and Custom Dates</span></div>
www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-19443155360557341062020-02-03T06:03:00.002-06:002022-01-24T08:54:27.861-06:00FAQ Series - Show - Hide Filters <h1 style="text-align: left;"><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1><h2 style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><blockquote style="border: none; font-size: medium; font-weight: 400; margin: 0px 0px 0px 40px; padding: 0px; text-align: left;"></blockquote><p style="font-size: medium; font-weight: 400; text-align: left;"><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p></span></h2><h2 style="text-align: center;"><span face=""arial" , "helvetica" , sans-serif"><br /></span></h2><h2 style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif">Show - Hide Filters</span></h2>
<div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div>
<span face=""arial" , "helvetica" , sans-serif">Often we will see a Forum question on how to "Filter the view without filtering the underlying data?" Really? </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">What's really going on ? </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Load a data set into Tableau, open the Data Source tab and look at the data - It is the complete data set </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHUzdu5wxXExvCxHKD_LkHdjTtu1sUWNeNx4b878_ZWxGQNiUdBc1G42KZWjLfShCzn8fSRFIoUF2C5PPeGmftkDnNCCM15ASmV4SJaS1fS2XJpIga3xM_Z8klYmkhOBaU9pbExkD2tas/s1600/Lookup+filters.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHUzdu5wxXExvCxHKD_LkHdjTtu1sUWNeNx4b878_ZWxGQNiUdBc1G42KZWjLfShCzn8fSRFIoUF2C5PPeGmftkDnNCCM15ASmV4SJaS1fS2XJpIga3xM_Z8klYmkhOBaU9pbExkD2tas/s640/Lookup+filters.png" width="640" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Now create a new worksheet with a simple chart </span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIan1nufQjU8Am8t35oF6yaBy52t7knyJ3IyxCeSJQdbomRQBnZnDHcADzexsKynM6Uex0kdHuLK9Dg-qQnIbm40hprEY6DbPrZMTjGP5v4HZG2PqnGTjN1zJm3yIm4jOCkcoJVTgc9RI/s1600/bar+chart.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="914" data-original-width="590" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIan1nufQjU8Am8t35oF6yaBy52t7knyJ3IyxCeSJQdbomRQBnZnDHcADzexsKynM6Uex0kdHuLK9Dg-qQnIbm40hprEY6DbPrZMTjGP5v4HZG2PqnGTjN1zJm3yIm4jOCkcoJVTgc9RI/s320/bar+chart.PNG" width="206" /></a></div>
<br />
<span face=""arial" , "helvetica" , sans-serif">Open the Analysis drop down and select View Data</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgasM63f6KaA1Sl5nqt4nj66CiffBlLZJckuiZrFXTg2gV82m4Xua0Sd5m2WgN8K5jbL9-TWM2YjuH-RVSP5IkX1R5HEOsn-IO5N9CGTAJ3P6wNNqVfp9uiTXttkYbAWc3hr6zYTjKRG10/s1600/view+data.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="687" data-original-width="625" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgasM63f6KaA1Sl5nqt4nj66CiffBlLZJckuiZrFXTg2gV82m4Xua0Sd5m2WgN8K5jbL9-TWM2YjuH-RVSP5IkX1R5HEOsn-IO5N9CGTAJ3P6wNNqVfp9uiTXttkYbAWc3hr6zYTjKRG10/s320/view+data.PNG" width="291" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span face=""arial" , "helvetica" , sans-serif">The window that opens is the "Underlying Table" for the worksheet</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj99NWs__6CtQI-HEB-3pCh_-TUA82TiSBhZzysRZVEV7jP1IXtRNU-NfF2d8ee21_rqFxj6ZEssnx3sCQw9ys9plKa-5KoIisoE4Ywm7r7E-JorsSPXNlqOUuz54hLeMJu1-QLnc-1quA/s1600/underlying+table.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="435" data-original-width="773" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj99NWs__6CtQI-HEB-3pCh_-TUA82TiSBhZzysRZVEV7jP1IXtRNU-NfF2d8ee21_rqFxj6ZEssnx3sCQw9ys9plKa-5KoIisoE4Ywm7r7E-JorsSPXNlqOUuz54hLeMJu1-QLnc-1quA/s400/underlying+table.PNG" width="400" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The table is a subset of the full data set - </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">In Tableau each worksheet has its own underlying table. As you bring dimensions and measures to the rows, columns and marks card they "Filter" the full data set - what is left is the underlay table for the worksheet and it is the only data from the data set you loaded available for that sheet.</span><br />
<br />
<span face=""arial" , "helvetica" , sans-serif">So what - </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">When you add filters to the viz it does affect the underlying table so it is not possible to "</span><span face=""arial" , "helvetica" , sans-serif">Filter the view without filtering the underlying data" but it is possible to use a table calculation to <b>Hide</b> data from the viz. </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">I like to think of it as creating a viewing window. Data that is in the window can be seen - that outside the window is hidden</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><b>Lookup() Function</b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">This example uses Superstore data and presents the running total of Sales by Category over all the Months-Years in the data set - It looks like this</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZFBB15SP0L8NDnW_n-oEJkX3B2wVWSNe-yjECCa1M4W17gDBhnGRfty9U0LwkiHTkHcVR4dhTBRTJpbO2_KlviTdke9EmAlUOH1SxQZ3HANg7fyX6mPNThCEFHSZ_FyzJX_JhayymMzw/s1600/running+total+sales.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZFBB15SP0L8NDnW_n-oEJkX3B2wVWSNe-yjECCa1M4W17gDBhnGRfty9U0LwkiHTkHcVR4dhTBRTJpbO2_KlviTdke9EmAlUOH1SxQZ3HANg7fyX6mPNThCEFHSZ_FyzJX_JhayymMzw/s640/running+total+sales.png" width="640" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Now you only want to show the running total for 2019 but you want to include the data form 2016-2018 ("</span><span face=""arial" , "helvetica" , sans-serif">Filter the view without filtering the underlying data"). Using Lookup() we will create a window based on the custom format at the year level of the Order Date </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Create a custom date on Year - we want to "Filter" by year - </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Open the Date pill then Create and then Custom Date</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBRUQnQBUcHZMqCXLD7C63khg5fFiWhNnRC5fuK2sdJeLbGkm6NRjPXot2nspXzPuQslM0i0wD7-7oegWkTHzRWMC6f4xREtQbkac9P_IxXsOKiDMTs0CIJ0VOQkAhxzLcOiBf7reoEH4/s1600/create+date+year.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBRUQnQBUcHZMqCXLD7C63khg5fFiWhNnRC5fuK2sdJeLbGkm6NRjPXot2nspXzPuQslM0i0wD7-7oegWkTHzRWMC6f4xREtQbkac9P_IxXsOKiDMTs0CIJ0VOQkAhxzLcOiBf7reoEH4/s640/create+date+year.png" width="640" /></a></div>
<br />
<br />
<span face=""arial" , "helvetica" , sans-serif">When the window opens Select Year from the Drop Down and the Date Part button (make the date discrete)</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj40Rh7-hFZR57gCIFV0Yiu54G-gLSlOWoay_In4f_mKVHSF3XQeQhEO_HB9YL-ElhIHn2JZp18r38GYt_-_K3-WxtMcRwMA-nn6loUfA9f7f8eYNcI82Ym7S7srDdupxD8cbysy4wGPNs/s1600/create+year.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="213" data-original-width="532" height="128" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj40Rh7-hFZR57gCIFV0Yiu54G-gLSlOWoay_In4f_mKVHSF3XQeQhEO_HB9YL-ElhIHn2JZp18r38GYt_-_K3-WxtMcRwMA-nn6loUfA9f7f8eYNcI82Ym7S7srDdupxD8cbysy4wGPNs/s320/create+year.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<span face=""arial" , "helvetica" , sans-serif">Now use Lookup - a table calculation - to read the year of each date in the table individually</span><span face=""arial" , "helvetica" , sans-serif"> - This works much like a Lookup in excel - in words it says " from the Order Date Years measure - return the value in the current cell" Note - the attr() all table calculation must be an aggregate</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuMJSu1LuOSf9ZxojSurpIPMTvgAymXYe8lBRui7udeP_wTEdYCQU5OjH48OkrKxJOZ6kQmUW_0yjEAu71Fn-lfUp7wqmSfXtrteINUWzCw_wmXthtMnbYb0oDm0lKNOgl1vFXRSeRIYk/s1600/Lookup+function.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="142" data-original-width="705" height="80" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuMJSu1LuOSf9ZxojSurpIPMTvgAymXYe8lBRui7udeP_wTEdYCQU5OjH48OkrKxJOZ6kQmUW_0yjEAu71Fn-lfUp7wqmSfXtrteINUWzCw_wmXthtMnbYb0oDm0lKNOgl1vFXRSeRIYk/s400/Lookup+function.PNG" width="400" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Then we add a conditional statement that will look each value of the actual Order Date (Years) either assign it as Show or Hide</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCIPHQ8UeYXuyPykyeUPmnenOS3zGhXU7eB1RNX_-zJP5Rd1c3NBiOveUwJzybFay6nVDaOiY9-IF_Z31HnqrQrkoFT23MARLxX6vsxuGnzT2nc9q2pELtDaBN3i_LT1Cg1osPagmQK_k/s1600/New+lookup+filter.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="149" data-original-width="763" height="123" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCIPHQ8UeYXuyPykyeUPmnenOS3zGhXU7eB1RNX_-zJP5Rd1c3NBiOveUwJzybFay6nVDaOiY9-IF_Z31HnqrQrkoFT23MARLxX6vsxuGnzT2nc9q2pELtDaBN3i_LT1Cg1osPagmQK_k/s640/New+lookup+filter.PNG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Create the viz. </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The real order date goes on columns and the running sum of sales on rows</span><br />
<span face=""arial" , "helvetica" , sans-serif">Add the Lookup Filter to the filter shelf and set to "Show" and calculate across (or by Order Date)</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR3izcE8VUZrQtUBKUpAdeUiRtGdtIPyA200Kgv629-mIcFdrgEXCKNWLWYcy9qDu3ZcTxZnaI3HLvEw294Chux8JOaTSLqv9wq-ONIUu2iz0F7CmmrSEHoytJP-hzt5u4EKhAGu-LtV4/s1600/create+the+filtered+viz.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR3izcE8VUZrQtUBKUpAdeUiRtGdtIPyA200Kgv629-mIcFdrgEXCKNWLWYcy9qDu3ZcTxZnaI3HLvEw294Chux8JOaTSLqv9wq-ONIUu2iz0F7CmmrSEHoytJP-hzt5u4EKhAGu-LtV4/s640/create+the+filtered+viz.png" width="640" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">and this is the result</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifcoAaTzAABiq_su2bPjFze5tl9Jea-MBhQgiXa2rNhpLVWz6HHTZq8PailON8VFtUxsFVy1SIeuKIyI62IOYtBY0pADlgKTs7Mrwy1x2o2JTyWPodHGXekyDhtVlLhspOnQ_8SAsV1RY/s1600/final+result.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifcoAaTzAABiq_su2bPjFze5tl9Jea-MBhQgiXa2rNhpLVWz6HHTZq8PailON8VFtUxsFVy1SIeuKIyI62IOYtBY0pADlgKTs7Mrwy1x2o2JTyWPodHGXekyDhtVlLhspOnQ_8SAsV1RY/s640/final+result.png" width="640" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The "window" is hiding January 2016 through December 2018 but allowing the 2019 data to be seen. The date is not really filtered out - the lookup filter window just hides the value you don't want to see</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><b>Last Function </b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span><span face=""arial" , "helvetica" , sans-serif">Frequently a user wants to compare the latest sales to the prior year same period - but they only want to see the last few weeks (or months). A solution is to use<b> Last()</b> - another table calculation - to create a dynamic viewing window -</span><br />
<br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">To show only the last 6 weeks create a "Last Show/Hide Filter" </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4bUlpycqGTNa62tsjPdMinX90a6HpAdoN5Hw1l4IyaZH8Ju4t_q4jfvymZ5wnN7NSlkLFr6zIcI6_JV433Od5iJ7aLbwnwLHkm-mCcWWFmRO9Nsl4CY7spSw8utTDioErsJVf-V-0HvI/s1600/last+filter.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="151" data-original-width="615" height="97" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4bUlpycqGTNa62tsjPdMinX90a6HpAdoN5Hw1l4IyaZH8Ju4t_q4jfvymZ5wnN7NSlkLFr6zIcI6_JV433Od5iJ7aLbwnwLHkm-mCcWWFmRO9Nsl4CY7spSw8utTDioErsJVf-V-0HvI/s400/last+filter.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">Adding a filter based on the last month date in the data base makes the viz dynamic for the YoY calculation</span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_S62LBFbpVpPNVhbVZzr37md7cQQZaY6_0f510P1fWqk1e7j7iVr5de8QE8MPsUGH9Y6jVOM9FmF2uz4sG2oBq30kCIOEVkMBlvEzUsqT9nskd-B-sY5OB-W7Se0fOjRHUzHlO40VgEs/s1600/max+month+filter.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="126" data-original-width="847" height="92" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_S62LBFbpVpPNVhbVZzr37md7cQQZaY6_0f510P1fWqk1e7j7iVr5de8QE8MPsUGH9Y6jVOM9FmF2uz4sG2oBq30kCIOEVkMBlvEzUsqT9nskd-B-sY5OB-W7Se0fOjRHUzHlO40VgEs/s640/max+month+filter.PNG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span face=""arial" , "helvetica" , sans-serif">Then create the viz</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The can be any level of discrete date parts - add a year filter to only include current and last year and set the Show/Hide filter to <b>Show</b> and the window will include the last 6 data part values - here weeks </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhktRniyDn0W_gLT6BRp0ycsUUIPY_H3HZ9h4BkEx9lMr4q_hN2v6-25w4FxfudOscsI-O9G56IUIuWkeSQ72zuAeYAfZoH31cwOfo66qr_L_kMrd_eT4o2liazdnhV5cfwnIxDNBn3M00/s1600/yoy+last.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhktRniyDn0W_gLT6BRp0ycsUUIPY_H3HZ9h4BkEx9lMr4q_hN2v6-25w4FxfudOscsI-O9G56IUIuWkeSQ72zuAeYAfZoH31cwOfo66qr_L_kMrd_eT4o2liazdnhV5cfwnIxDNBn3M00/s640/yoy+last.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The viz will dynamically adjust to the last 6 weeks when the database is updated </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">These are just 2 examples - obviously there can be many more.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">It is important to remember that table calculations are used to create the viewing window. They are at the bottom of the Order of Operation (a topic for another day) and work on the final fully filtered table that underlays the specific worksheet </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Hope this helps </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Jim</span></div>
www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-27246726609231470292020-01-27T14:31:00.004-06:002022-02-02T13:11:34.301-06:00FAQ Series - Not all NULLS are created equal<span style="font-size: large;">My Blog has moved - <a href="https://jimdehner.com/2020/01/27/faq-series-not-all-nulls-are-created-equal/" target="_blank">UPDATED blog post</a></span><br />
<h2 style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif">Not all Nulls are created equal? - Really?</span></h2>
<div>
<span face=""arial" , "helvetica" , sans-serif">Nulls - they break your calculations and mess with your charts but why are they difficult to fix?</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">There are 2 types of nulls each has a different solution</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><b>Empty Cell Null</b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The easiest to understand and to fix is the Empty Cell Null in your data set. In this simple data set it is easy to see there is an empty cell (a null) for Cats in the South</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgs94lOUDJaxwpYB-VMkOgP9p8vMzO5p9QhpE6i5zXRRqtENu5lpr3mqN2L1JF0-zsTAkb2ijk3wEGCA9mZJ0kUfhttT-qjF2lwDdUK_NuaZ_9tnh7Y6wJjrhHPNxAp0H1bPEYpaq3LnDo/s1600/empty+cell.GIF" style="margin-left: 1em; margin-right: 1em;"><span face=""arial" , "helvetica" , sans-serif"><img border="0" data-original-height="163" data-original-width="261" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgs94lOUDJaxwpYB-VMkOgP9p8vMzO5p9QhpE6i5zXRRqtENu5lpr3mqN2L1JF0-zsTAkb2ijk3wEGCA9mZJ0kUfhttT-qjF2lwDdUK_NuaZ_9tnh7Y6wJjrhHPNxAp0H1bPEYpaq3LnDo/s1600/empty+cell.GIF" /></span></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<span face=""arial" , "helvetica" , sans-serif">When the spreadsheet is loaded into Tableau and viewed on the Data Source tab it is still easy to see there is an empty cell</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg99H7ckDr1_uZ779Y5DlCA6jhgQLZa1xTxekD3zPUzMqr_DPBemrU1Ye1Z576a7V4de-N9wLth682XyY6dugpfXr0i_N-SaAlBVck3dOND8NLsXSpBnhIRFLjo_BNgZULapyaDKrSO0oE/s1600/loaded+null+cell.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="617" data-original-width="578" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg99H7ckDr1_uZ779Y5DlCA6jhgQLZa1xTxekD3zPUzMqr_DPBemrU1Ye1Z576a7V4de-N9wLth682XyY6dugpfXr0i_N-SaAlBVck3dOND8NLsXSpBnhIRFLjo_BNgZULapyaDKrSO0oE/s320/loaded+null+cell.GIF" width="299" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">There is a record for the combination of South and Cats but there is no value in the record. Tableau will interpret it as a Null value - </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtYYRTahrRyvCJ7p2Vt1_ha7tdyUdqoD3US1zzqgSvlceHJ81zBf75OtNu_Vt2lB5Bsg2JxIYqmmqDxHrv084xnIIz9DL5C_SQShFVElg8rD35wqnMRC5IcWgDjeMy5qUhsIeyLQDSPhg/s1600/null+in+cats.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="407" data-original-width="644" height="202" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtYYRTahrRyvCJ7p2Vt1_ha7tdyUdqoD3US1zzqgSvlceHJ81zBf75OtNu_Vt2lB5Bsg2JxIYqmmqDxHrv084xnIIz9DL5C_SQShFVElg8rD35wqnMRC5IcWgDjeMy5qUhsIeyLQDSPhg/s320/null+in+cats.GIF" width="320" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The empty cell null value is easy to fix with the ZN() function (ZN for Zero Null)</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV9QFffkD-FKyFNp_bLtuAGm6F0SXDPDtszYS6NhBKCl28rcla8lcCk8AKuwJsLMlJkr6ToFQM1GyjSjlTggdTxGPtZdiciwNcsAN6aIIZfO_uyM4b3WSuRnuyVySWFVyw8UwoqDD5Z1U/s1600/zn+cats.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="473" data-original-width="982" height="192" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV9QFffkD-FKyFNp_bLtuAGm6F0SXDPDtszYS6NhBKCl28rcla8lcCk8AKuwJsLMlJkr6ToFQM1GyjSjlTggdTxGPtZdiciwNcsAN6aIIZfO_uyM4b3WSuRnuyVySWFVyw8UwoqDD5Z1U/s400/zn+cats.GIF" width="400" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><b>No Record Null</b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">What happens when the data is missing the entire record - The preferred data structure for Tableau would be a tall and narrow set like this</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjM_75O4BWt2fCtVJSyMk0U7Zcn88-RUSuvc_zLiVzqxa-DUPIshAIO-hdSxKQJ9QQbqGhLtsxiLIDbND97EHRJgdHOZMtlXyGzY73uKTPgkmuc_mIpvUzPn1nL7f_T3zYY1bBEkCey5KI/s1600/pivoted+dogs+and+cats.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="260" data-original-width="390" height="213" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjM_75O4BWt2fCtVJSyMk0U7Zcn88-RUSuvc_zLiVzqxa-DUPIshAIO-hdSxKQJ9QQbqGhLtsxiLIDbND97EHRJgdHOZMtlXyGzY73uKTPgkmuc_mIpvUzPn1nL7f_T3zYY1bBEkCey5KI/s320/pivoted+dogs+and+cats.GIF" width="320" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Now it is not as easy to see there is no data for South Cats - This is an example of the second type of Null - the No Record Null - and it can't be fixed with using ZN()</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7rMb_KGQNCAxUlWtwExF4AbLH7jRFfeRQwYtWvEIZek5eREs2Vdo-f32rHXLtUFjNr_Nk3NtUo2SkZKt_OilsNfNM6tOFMcFeU_ffAfaiB7ZpvwAE6_ik3SQ5YIN6AUA01nNyJo-rk_M/s1600/zn+won%2527t+work.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="500" data-original-width="736" height="271" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7rMb_KGQNCAxUlWtwExF4AbLH7jRFfeRQwYtWvEIZek5eREs2Vdo-f32rHXLtUFjNr_Nk3NtUo2SkZKt_OilsNfNM6tOFMcFeU_ffAfaiB7ZpvwAE6_ik3SQ5YIN6AUA01nNyJo-rk_M/s400/zn+won%2527t+work.GIF" width="400" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">There is no record South/Cats so there is no null value in a record to "zero out"</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">You can force a 0 in the viz using a lookup function <span style="font-size: x-small;">(NOTE this does NOT create a South /Cats record in the data set)</span></span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif">ifnull(lookup(sum(Quantity),0),0)</span></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSgfNbHkVCLpj3dO-fZgl2VZYXnUlmQDk-wsVpbRysglFtAN4GWd7ui3ejcSvC6lv-ufFYLH59swawWTSXNf5JHMaWqartXwNDl8mlEEii2A-TLYTRgNDo7M_AB9KOBmxZcPohX6EOTAE/s1600/fill+null+example.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSgfNbHkVCLpj3dO-fZgl2VZYXnUlmQDk-wsVpbRysglFtAN4GWd7ui3ejcSvC6lv-ufFYLH59swawWTSXNf5JHMaWqartXwNDl8mlEEii2A-TLYTRgNDo7M_AB9KOBmxZcPohX6EOTAE/s640/fill+null+example.png" width="640" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face="arial, helvetica, sans-serif">You are able to place a value into a view but other functionality is limited. Lookup is a table calculation performed at the bottom (last) in the Order of Operation. Table calculations areexecuted after all filters have been applied and all other calculations have been performed - The work on the underlaying table for the worksheet and are only performed at the aggregate level </span><br />
<span face="arial, helvetica, sans-serif"><br /></span>
<span face="arial, helvetica, sans-serif">Lets see what that means in practice:</span><br />
<span face="arial, helvetica, sans-serif"><br /></span>
<span face="arial, helvetica, sans-serif">Running total is another table calculation and it can be applied to the Fill Null calculation and note that the Grant Total also returns the correct result</span><br />
<span face="arial, helvetica, sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNHx6eB03uWtZd8HLk_XtuZD2F4c5nHf2BCAFx2yzTilJ3Fjxvzi_UKKoQu7gONo92kJ_kGOA0oHi4_-PEfKJ_qTmnnCH8fGsMvKns5fsnWJinRcflcsRT-vcmi7AUMgP4deYOA1WOhFc/s1600/running+total+returns+correct.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="705" data-original-width="1077" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNHx6eB03uWtZd8HLk_XtuZD2F4c5nHf2BCAFx2yzTilJ3Fjxvzi_UKKoQu7gONo92kJ_kGOA0oHi4_-PEfKJ_qTmnnCH8fGsMvKns5fsnWJinRcflcsRT-vcmi7AUMgP4deYOA1WOhFc/s320/running+total+returns+correct.GIF" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span face="arial, helvetica, sans-serif"><br /></span>
<span face="arial, helvetica, sans-serif">likewise Rank_Unique will return the correct Rank for a Fill Null 0</span><br />
<span face="arial, helvetica, sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvPZbmmFiKznUe0xd-NyCQWQEjozJxCs-h7I_LcT1EaUcCXQs6mE-K2oMjcbXP0-C67hGPT3apxf5ISurbAQ1L-PQUa_V8eT3-7V-MCAUCd0LIE1pCsUa7GML40L0Oy98bEomMcnR3Ecw/s1600/rank+fill+null+correct.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="682" data-original-width="924" height="236" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvPZbmmFiKznUe0xd-NyCQWQEjozJxCs-h7I_LcT1EaUcCXQs6mE-K2oMjcbXP0-C67hGPT3apxf5ISurbAQ1L-PQUa_V8eT3-7V-MCAUCd0LIE1pCsUa7GML40L0Oy98bEomMcnR3Ecw/s320/rank+fill+null+correct.GIF" width="320" /></a></div>
<span face="arial, helvetica, sans-serif"><br /></span>
<span face="arial, helvetica, sans-serif"><br /></span>
<br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Most users want to total the data using Grand Totals - seems to return the correct value</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZcr6iTWfgCCLfEQpef0x4UMRVmMXeDBeDsuR1cUU7Y7Ker6pjBhHmp8wHjz3PTHBcVaG7I4MJPLGv3e6WtkIrp7pq874zp30fCorVKoQ8tv8NgBh8d-HR9vKlmpvHJWCwGouHnNCEcSo/s1600/total+using+sum.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="536" data-original-width="826" height="258" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZcr6iTWfgCCLfEQpef0x4UMRVmMXeDBeDsuR1cUU7Y7Ker6pjBhHmp8wHjz3PTHBcVaG7I4MJPLGv3e6WtkIrp7pq874zp30fCorVKoQ8tv8NgBh8d-HR9vKlmpvHJWCwGouHnNCEcSo/s400/total+using+sum.GIF" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<span face=""arial" , "helvetica" , sans-serif">But see what happens when we try to get an average the results do not meet expectations - averaging the quantity returns 80/3 for 26.7 not the 20 (80/4) because there are only 3 marks (real records) in the viz- The total on Fill Null can only be set to Automatic and returns the sum of the records</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFDzpyijiKXxQVq73VVNZHla-nzaIj2jqT8hmypRGnBPM935hzsKcgROLvBGVMYq9OfHrD824kYOIDeIHgmR36Nb2esEwB4eq3yKkOs2y0RVf6Ki_8pUMhOPUo369aq9lEo8lafIhESZk/s1600/averages+are+wrong.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="789" data-original-width="1041" height="242" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFDzpyijiKXxQVq73VVNZHla-nzaIj2jqT8hmypRGnBPM935hzsKcgROLvBGVMYq9OfHrD824kYOIDeIHgmR36Nb2esEwB4eq3yKkOs2y0RVf6Ki_8pUMhOPUo369aq9lEo8lafIhESZk/s320/averages+are+wrong.GIF" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Using the Average in the "Fill Null" calculation will result in a total that is 26.7 (80/3) again</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8nH0RO-GCATnaVbw7tvtJJjQwkX7EczAW_kLQW5xf5LCorna6z1fUQuqHGb1zVTiYiHvlLGAbY1kxjvE-gN28dmEIMpmZLxbBzqpoLBerPQSzwjrMK_3jf4D7PMl2b4U2P_W1NO3RHos/s1600/avg+fill+null.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="112" data-original-width="323" height="110" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8nH0RO-GCATnaVbw7tvtJJjQwkX7EczAW_kLQW5xf5LCorna6z1fUQuqHGb1zVTiYiHvlLGAbY1kxjvE-gN28dmEIMpmZLxbBzqpoLBerPQSzwjrMK_3jf4D7PMl2b4U2P_W1NO3RHos/s320/avg+fill+null.GIF" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhH_HesPOov-RT5Tg9PLbIYoRDMRx1AMHT3iseYpUDPi__fnyd1ygESrQyTUdSLiQ9n6uG2D4psfM4RTVxml4TeUDv9X4zPI-MmPRFn-btnT6J1_hi0WL1E5c3e6m1w3nPQc3WXjphyphenhyphenzc/s1600/wrong+avg+fill+null+total.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="446" data-original-width="816" height="174" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhH_HesPOov-RT5Tg9PLbIYoRDMRx1AMHT3iseYpUDPi__fnyd1ygESrQyTUdSLiQ9n6uG2D4psfM4RTVxml4TeUDv9X4zPI-MmPRFn-btnT6J1_hi0WL1E5c3e6m1w3nPQc3WXjphyphenhyphenzc/s320/wrong+avg+fill+null+total.GIF" width="320" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face="arial, helvetica, sans-serif">and the Lookup can not be used LOD expressions</span><br />
<span face="arial, helvetica, sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkYaOefWRB5PRQo3GF-gdRbA1viGPZr5XXzRHUaikZPcGKZUimoT7HR3BLyFaxsLasSkSr5muIeKFC8XdefyAsQoxd6ozXT6HMD0s56i_tekShPk8SIZ9-8bBxeiiUZDSKsMdqsVzXRJc/s1600/can+not+in+lod.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="611" data-original-width="706" height="345" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkYaOefWRB5PRQo3GF-gdRbA1viGPZr5XXzRHUaikZPcGKZUimoT7HR3BLyFaxsLasSkSr5muIeKFC8XdefyAsQoxd6ozXT6HMD0s56i_tekShPk8SIZ9-8bBxeiiUZDSKsMdqsVzXRJc/s400/can+not+in+lod.GIF" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span face="arial, helvetica, sans-serif">and it can't create a record in the data table - Here the table doesn't contain South and Null Fill has no place to put a 0</span><br />
<span face="arial, helvetica, sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEmlzx0lKb57qnqyHbUECe7k3f3WV9-oQDuvDsV4Gteg9GwHHqnQOgiVsqLErfCsbfMJn8ClXNeR5eYibzHSVKFEPvXT6Nb5hdMPV2nVy-bn8tufJVgOx2OH4mAO_OysN3ghm5j6ohqFU/s1600/can%2527t+create+record.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="581" data-original-width="965" height="192" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEmlzx0lKb57qnqyHbUECe7k3f3WV9-oQDuvDsV4Gteg9GwHHqnQOgiVsqLErfCsbfMJn8ClXNeR5eYibzHSVKFEPvXT6Nb5hdMPV2nVy-bn8tufJVgOx2OH4mAO_OysN3ghm5j6ohqFU/s320/can%2527t+create+record.GIF" width="320" /></a></div>
<span face="arial, helvetica, sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">So using a lookup formula to fill a No Record Null has its limit - What can you do</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><b>Padding or Scaffolding</b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">You will need to create a record in the data (think like a cell in excel) that can be addressed with combination of dimensions - here South/Cats - to complete the data set - the technique is referred to a "Padding" or "Scaffolding"</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Its not difficult but takes a couple steps - Make a separate file that list the every combination of the dimensions you will need in the analysis - </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVX2JxNaCW6Bu19otgsA79EgB7YsgfFWHTTG63cnWi6Oaus7SPac52lgam5j74CMEhdCU65HK-ziMgUdc0TYJt95huqKMsOj55jk0-bGK5RJoF9BUISkxZLFTHcU6mxn4M_PKqhC28RPU/s1600/scaffold.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="351" data-original-width="276" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVX2JxNaCW6Bu19otgsA79EgB7YsgfFWHTTG63cnWi6Oaus7SPac52lgam5j74CMEhdCU65HK-ziMgUdc0TYJt95huqKMsOj55jk0-bGK5RJoF9BUISkxZLFTHcU6mxn4M_PKqhC28RPU/s320/scaffold.GIF" width="251" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Upload the file to Tableau and Left Join it with your data - the missing records are added and the measure value is entered as a "Empty Cell Null" - </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtEmhLbxR9p9Pxtl-eOqDYk89psvQyueKjhFfBEA0n_fWe50kygPUd8AqvLe9EyNuL1JLwxXVHsFIJFIrgEqNq6FniX5_alsYfTUxOZCvxmlqIitfNFwcS6Hs2OjHBBTGRCnNXvGllGqY/s1600/scaffold+join.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtEmhLbxR9p9Pxtl-eOqDYk89psvQyueKjhFfBEA0n_fWe50kygPUd8AqvLe9EyNuL1JLwxXVHsFIJFIrgEqNq6FniX5_alsYfTUxOZCvxmlqIitfNFwcS6Hs2OjHBBTGRCnNXvGllGqY/s640/scaffold+join.png" width="640" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The table is now complete and empty cell nulls can be used in any formula using the ZN() function </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTicbZzGo8M26vgQy_sGr0Msr8tp6_2ivDQVZt17HoXnNsJaUb1Gnh951YOspFVTbCdSIb6JdBANyMc9uXMwwT1yN0lmLaUhSsTqyrdAwLhyphenhyphenVzv-c1qgXDmjMSqKYhjF77mgwEZFJz-24/s1600/zn+after+scaffold.GIF" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="163" data-original-width="295" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTicbZzGo8M26vgQy_sGr0Msr8tp6_2ivDQVZt17HoXnNsJaUb1Gnh951YOspFVTbCdSIb6JdBANyMc9uXMwwT1yN0lmLaUhSsTqyrdAwLhyphenhyphenVzv-c1qgXDmjMSqKYhjF77mgwEZFJz-24/s1600/zn+after+scaffold.GIF" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">ZN fills the cell with a 0 and the value can be used in any type of calculation - here a simple total using average - </span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVzzyI0fSRS7e1jyQmYhFETpA6D_uLfaKdYWhxTA2nTbtFgyny7H2E389b_MohZ7oTF8CUvy6MXt0dsTMe5NN07jbMJGPZQ19laFHQsnZjiXZU-fMc1YhsU0Ja-bX7QDaID1U5Lazy32U/s1600/after+scafflod+correct+average.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVzzyI0fSRS7e1jyQmYhFETpA6D_uLfaKdYWhxTA2nTbtFgyny7H2E389b_MohZ7oTF8CUvy6MXt0dsTMe5NN07jbMJGPZQ19laFHQsnZjiXZU-fMc1YhsU0Ja-bX7QDaID1U5Lazy32U/s640/after+scafflod+correct+average.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif">Obviously an elementary examples that illustrate that all nulls are not created equal</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The next time you are face with a Null problem - think about which type you have </span><br />
<br />
<span face=""arial" , "helvetica" , sans-serif">If the data table is complete but there is an empty cell </span><span face=""arial" , "helvetica" , sans-serif"> wrap the calculation in <b>ZN() </b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><br />If the data table is missing records and</span><span face="arial, helvetica, sans-serif"> you need to place </span><span face="arial, helvetica, sans-serif">a 0 (or other value) in the chart you can use the Lookup table calculation </span><b style="font-family: arial, helvetica, sans-serif;">Ifnull(lookup(sum(measure),0),0)</b><br />
<span face="arial, helvetica, sans-serif"></span></div>
<div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">But if the data set is missing records and you need to use a "No Record Null" cell value in other calculations then <b>Padding or Scaffold</b> is the choice</span><br />
<ul></ul>
<span face=""arial" , "helvetica" , sans-serif">I hope it helped you better appreciate Nulls</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Enjoy</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Jim</span><span face=""arial" , "helvetica" , sans-serif"> </span></div>
<div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-22683080914441241872020-01-21T07:50:00.001-06:002020-01-21T07:50:21.416-06:00FAQ Series- Cannot Mix Aggregate and Non-aggregate <h2 style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"> Cannot Mix Aggregate and Non-aggregate </span></h2>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Look familiar:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2UwX4FaiSVHxK54RsdHn1UfNolv3KZ_S_5QlbTyrInDCf0jbYl8jGZWJ2qAlZD4WFT2bpNGOd3dulHofP61hTqouV9F92S7HPb_OgaOrS3wvGd5mgRdLCIx0XSF3z47OqCQ1Ep-4bw94/s1600/error+message+text.GIF" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="27" data-original-width="443" height="38" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2UwX4FaiSVHxK54RsdHn1UfNolv3KZ_S_5QlbTyrInDCf0jbYl8jGZWJ2qAlZD4WFT2bpNGOd3dulHofP61hTqouV9F92S7HPb_OgaOrS3wvGd5mgRdLCIx0XSF3z47OqCQ1Ep-4bw94/s640/error+message+text.GIF" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">One of the most frequent questions we see on the Forum results from trying mixing aggregate and non-aggregates in the same calculation - But why is that a problem and how do you resolve it -</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Next time you load a data file into Tableau, open the data source tab and spend a moment to look at the data structure. This might look like a spreadsheet </span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix8oTgNwRzciySvoZ70jsum3n5wTGOSsRo4BwwjMP2ZOckoMgKnNyytx9kcIHhQxjbBnM-xpPu95t5rWi05S1UoAaC9PrF-zm_Ro9ZOIVdbUm2YP5uLkn9S0kfxk7mXrn58QrnxtJCxSg/s1600/simple+data+source.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="442" data-original-width="526" height="268" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix8oTgNwRzciySvoZ70jsum3n5wTGOSsRo4BwwjMP2ZOckoMgKnNyytx9kcIHhQxjbBnM-xpPu95t5rWi05S1UoAaC9PrF-zm_Ro9ZOIVdbUm2YP5uLkn9S0kfxk7mXrn58QrnxtJCxSg/s320/simple+data+source.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now, open a worksheet and make a calculation to determine the Profit Percent as Profit / Sales </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgs0i7k0giNjHQtEtw_DKJxlhiiJdMZKtiDlClQdhJgxPAP3tQQ8iGw_m6PgpBsOBcjkbzG0UJxI_Wog3yZ9XEHewMEgaRfkv5mTFscy_dXez-qHPoKjWRRu80EBl2YGygIe2oRYJ164xE/s1600/incorrect+profit+percent.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="103" data-original-width="243" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgs0i7k0giNjHQtEtw_DKJxlhiiJdMZKtiDlClQdhJgxPAP3tQQ8iGw_m6PgpBsOBcjkbzG0UJxI_Wog3yZ9XEHewMEgaRfkv5mTFscy_dXez-qHPoKjWRRu80EBl2YGygIe2oRYJ164xE/s1600/incorrect+profit+percent.PNG" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Return to the data source tab and a Column (Measure) has been added to the table with the results of the calculation for each "Row" of data - It's just what we'd expect from a spreadsheet calculator </span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLKp1nNHtVc-4V8FusVttOHPQ_sXuZxfVKZboaQbPw7HWHRr6yjy8K2iqv4hJ7ru9gFFkj-HhK2DnGAt-BL3CBBsA34v5NUaxNqzwVFT6YC6OJb2d1UoROWbAlkvUdqrqnV24cvdrTmpU/s1600/data+source+with+incorrect+profit+percent.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="445" data-original-width="656" height="271" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLKp1nNHtVc-4V8FusVttOHPQ_sXuZxfVKZboaQbPw7HWHRr6yjy8K2iqv4hJ7ru9gFFkj-HhK2DnGAt-BL3CBBsA34v5NUaxNqzwVFT6YC6OJb2d1UoROWbAlkvUdqrqnV24cvdrTmpU/s400/data+source+with+incorrect+profit+percent.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Go to the worksheet and make a viz with totals and subtotals. Whats going on? The row profit percents are correct but the totals and subtotals are wrong</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ5JWPjkSqLBPvpFjFd-uJRC73aOINYYgmni0DF7eVUJDitKxIqCU9fjDHL6EZ5fg9dG8Ukpmjr9qmoaQOhWfd2uVHPTsoOOxiKBSekArrPADtWzv5NpAq3ZrDB6XGi5RjWsJOEFxOGoE/s1600/incorrect+viz+profit+totals.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="546" data-original-width="673" height="259" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ5JWPjkSqLBPvpFjFd-uJRC73aOINYYgmni0DF7eVUJDitKxIqCU9fjDHL6EZ5fg9dG8Ukpmjr9qmoaQOhWfd2uVHPTsoOOxiKBSekArrPADtWzv5NpAq3ZrDB6XGi5RjWsJOEFxOGoE/s320/incorrect+viz+profit+totals.PNG" width="320" /></a></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Tableau aggregates measures as they are brought to the viz so the individual profit percents are summed in the viz - the problem started with the calculation - Sales and Profit need to be aggregated in the calculation</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik2oMjL-oIvuOpsEwVR-u9RfKAQCaVBUbSET4pQTzV-K-Um5Tlau3jCOHIKfCiptBQq_7ai31HMnQ0ZKlIaPijjvZ9NMF_GgVMVq8TrY5CE7YWSQEE-h6kuNxY5HejTNwfOQ6BUIsHRSA/s1600/correct+percent+of+total+calc.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="153" data-original-width="310" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik2oMjL-oIvuOpsEwVR-u9RfKAQCaVBUbSET4pQTzV-K-Um5Tlau3jCOHIKfCiptBQq_7ai31HMnQ0ZKlIaPijjvZ9NMF_GgVMVq8TrY5CE7YWSQEE-h6kuNxY5HejTNwfOQ6BUIsHRSA/s1600/correct+percent+of+total+calc.PNG" /></a></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Now on the Data Source tab the Aggregate Profit Percent look just like the Simple values</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinUZxopwQxTegoM6R8Wrfq33cBzO-uhz6yxQ2ie3P5ZUgT1mYIuR4da6NpPFCuc_Ocw4DikCnHsz3pR1-ovYhN80vTOkdhJxAxe3JhhDIT-dGI8vVvcYo87tmptkynI0AJxQ6EZXSVbKI/s1600/correct+data+sorce.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="433" data-original-width="736" height="235" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinUZxopwQxTegoM6R8Wrfq33cBzO-uhz6yxQ2ie3P5ZUgT1mYIuR4da6NpPFCuc_Ocw4DikCnHsz3pR1-ovYhN80vTOkdhJxAxe3JhhDIT-dGI8vVvcYo87tmptkynI0AJxQ6EZXSVbKI/s400/correct+data+sorce.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">But when we add the new measure to the viz we get the correct totals and subtotals</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Note also the measure is brought to the viz as and (AGG)regate</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzUsKMDth3yteP_7rbi6GtsaFUwOJIF13Y-OmHVMu-vz2GS74nUIvzgEBMFveZnYgmiIIIeDshpkYuGjlHNnsHgtHiZSnW4a_vZ9qwBElGj4KOPElgxxlQ2ICBwWUvdQ5MoWwCCZFmVk0/s1600/Correct+viz.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzUsKMDth3yteP_7rbi6GtsaFUwOJIF13Y-OmHVMu-vz2GS74nUIvzgEBMFveZnYgmiIIIeDshpkYuGjlHNnsHgtHiZSnW4a_vZ9qwBElGj4KOPElgxxlQ2ICBwWUvdQ5MoWwCCZFmVk0/s640/Correct+viz.PNG" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">So you can see how using aggregation in a calculation will affect the result but it is also the source of the aggregate - non-aggregate problem. </span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIAF_veL9ICGpB689Q46GCYSVLFLuhfpvsIiJqS0njBEDgFSRK5nOT_U_YYEIOsirqmEAWIuyK5o4uEQ2ZhpHPtiUVq-LBz7GUuwlkUk8cYOp9OWLsqm2uyooyyUEzUjXeYltHh_eeV5E/s1600/error+message.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIAF_veL9ICGpB689Q46GCYSVLFLuhfpvsIiJqS0njBEDgFSRK5nOT_U_YYEIOsirqmEAWIuyK5o4uEQ2ZhpHPtiUVq-LBz7GUuwlkUk8cYOp9OWLsqm2uyooyyUEzUjXeYltHh_eeV5E/s640/error+message.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">The message simply means that if one dimension or measure is aggregated in a calculation then ALL the measures and dimensions in the calculation must be aggregated </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFZxhbYzRrJaAse_Z2zcj9ZnhB2IxGTu42srDb2BNXJqo3C3dWK9pwA1iKlXd99WK0qceIS89XGle-mWntZd50GcJZha0aiE3Lc-yFvOgfO4CW1JyE5OEdG6VM1-9iU0jE9JVkU0L7mbo/s1600/correct+simple+profit+ratio.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="333" data-original-width="535" height="248" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFZxhbYzRrJaAse_Z2zcj9ZnhB2IxGTu42srDb2BNXJqo3C3dWK9pwA1iKlXd99WK0qceIS89XGle-mWntZd50GcJZha0aiE3Lc-yFvOgfO4CW1JyE5OEdG6VM1-9iU0jE9JVkU0L7mbo/s400/correct+simple+profit+ratio.PNG" width="400" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">- But sometimes it is not easy to see which dimension or measures need to be aggregated. See the following examples:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>1-Table Calculations</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Table calculations are aggregations so other measures in the calculation need to be aggregate too - here Difference is a table calculation so Sales needs to be aggregated :</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAgEYUayTljJpUO0YEF5Jhpe0KhZNZDIXRv6sAhNnglYetBTv972ppt9b39nsEqIvXoD7ncDOPJydF9wCQW7aC7roy98jy8RU1bGuq8cZBa2cujwQ_6ACka1MOXt0lg39HbJW3UWGORhw/s1600/Table+Calculation.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAgEYUayTljJpUO0YEF5Jhpe0KhZNZDIXRv6sAhNnglYetBTv972ppt9b39nsEqIvXoD7ncDOPJydF9wCQW7aC7roy98jy8RU1bGuq8cZBa2cujwQ_6ACka1MOXt0lg39HbJW3UWGORhw/s640/Table+Calculation.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Aggregating Sales with Sum() solves the problem </span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbTK-zOdwrIIiVvCNhandvvC06PzOdLSp49bcVe-36eqBBp6XVci48WMlLWs8UBpuBsjdTwMhDiIW6EStWHMnD7U0zE8VMnL1EAumF-bp7hyphenhyphenwYs3TwytPDOFvywSeFBouCJfbfwtzgj0k/s1600/table+calc+correct.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="316" data-original-width="509" height="198" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbTK-zOdwrIIiVvCNhandvvC06PzOdLSp49bcVe-36eqBBp6XVci48WMlLWs8UBpuBsjdTwMhDiIW6EStWHMnD7U0zE8VMnL1EAumF-bp7hyphenhyphenwYs3TwytPDOFvywSeFBouCJfbfwtzgj0k/s320/table+calc+correct.PNG" width="320" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>2-Embedded Dates</b></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Often dates are embedded in a calculation that includes an aggregation - </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9-lf5bnHLpMOTv5HRZb3EwRL5Mm_F2A12pUF-l-X8LKb0CY0btWA87fLugPK1LBPQNAC4zXPBtZ2sI5g3e9zz0Wl82oj-9qzHVe3Pxtr7SlPcQEknMRh2bhmgGB8mp24wzaSCSMPmGXk/s1600/embedded+dates.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9-lf5bnHLpMOTv5HRZb3EwRL5Mm_F2A12pUF-l-X8LKb0CY0btWA87fLugPK1LBPQNAC4zXPBtZ2sI5g3e9zz0Wl82oj-9qzHVe3Pxtr7SlPcQEknMRh2bhmgGB8mp24wzaSCSMPmGXk/s640/embedded+dates.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Here Sales in aggregated so Order Date and Ship Date need to be aggregated - Wait aggregate Dates - sure Dates and string (text) dimension can be aggregate with Attr(), Min() or Max() - your choice will depend on the analysis you are doing</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">This is just one way around the problem</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0cIy-BwoAzPEvB_bIwuTlem3UeqLk6_yOHWRbYlCVBGGONQNnTmGJpMMbiW_jTBGfKy2h7RDbzmuQq6UdB6Sz1wMwGhaFojsgrYCZbEA7A1YysIWQ99rWo_yv7tdxKWH9pRjkv_waEQc/s1600/embedded+date+solution.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><img border="0" data-original-height="184" data-original-width="687" height="106" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0cIy-BwoAzPEvB_bIwuTlem3UeqLk6_yOHWRbYlCVBGGONQNnTmGJpMMbiW_jTBGfKy2h7RDbzmuQq6UdB6Sz1wMwGhaFojsgrYCZbEA7A1YysIWQ99rWo_yv7tdxKWH9pRjkv_waEQc/s400/embedded+date+solution.PNG" width="400" /></span></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: x-small; text-align: left;"><span style="font-family: "arial" , "helvetica" , sans-serif;">Note: removing the sum() from sales would also work</span></span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><b>3 Aggregations cause by LOD's</b></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Sometimes, dimensions within an LOD cause the problem - The argument in an LOD must be aggregated - here Sales is aggregated but Category is not </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX7TLSoENzSaSnCklFUujiVtTuvVzZhHwv0mYXhkpk02H3FrH1fd-ASF6dpDir7Ke0QSYIt0NJtc3nArpwdhrqcpCSdpOkYLE7dh8-d7TdxxG4L-vdiVQC1702CHToBzaUHt8tPzipETo/s1600/lod+embedded.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX7TLSoENzSaSnCklFUujiVtTuvVzZhHwv0mYXhkpk02H3FrH1fd-ASF6dpDir7Ke0QSYIt0NJtc3nArpwdhrqcpCSdpOkYLE7dh8-d7TdxxG4L-vdiVQC1702CHToBzaUHt8tPzipETo/s640/lod+embedded.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">There are 2 solutions - the first is use a Min() or Max to aggregate the Category <span style="font-size: x-small;">(Note: Attr() can not be used in an LOD)</span></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbD6BVMiGALaXwJVLjM8wHSj3ALaFjUeDyTR23bSAaYa07Yq0xAsAfH_XocerU5HNpfBPM7FYXmk85_SSrbbcHzsJrk505b-iOFGnL-s5aHEHHXTYFVWXqaRHGxE9S0ISx08mG2rJNPeo/s1600/lod+change+to+min.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="313" data-original-width="792" height="157" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbD6BVMiGALaXwJVLjM8wHSj3ALaFjUeDyTR23bSAaYa07Yq0xAsAfH_XocerU5HNpfBPM7FYXmk85_SSrbbcHzsJrk505b-iOFGnL-s5aHEHHXTYFVWXqaRHGxE9S0ISx08mG2rJNPeo/s400/lod+change+to+min.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The second is to move the Sum() outside the conditional statement in the LOD</span></div>
<div class="" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu6gHPyjckMu_KRr2eCVXES2V2j7FcBvWRrO8wMTclSmvg61pi2A7-CyYCE0oZdTZoY_sTPTozXft0O9t62dRPMhexWc2_khyphenhyphenvKwHrCufjFO9IvBiOhpWKoZnGsE4gqZTEExOnHiJuQeI/s1600/sum+outside+the+lod.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="306" data-original-width="777" height="157" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu6gHPyjckMu_KRr2eCVXES2V2j7FcBvWRrO8wMTclSmvg61pi2A7-CyYCE0oZdTZoY_sTPTozXft0O9t62dRPMhexWc2_khyphenhyphenvKwHrCufjFO9IvBiOhpWKoZnGsE4gqZTEExOnHiJuQeI/s400/sum+outside+the+lod.PNG" width="400" /></a></div>
<div class="" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Either solution will work</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>4 Using an LOD to resolve an aggregation problem</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">This example calculates the COGS percent to Sales</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">determine COGS:</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVptBWJVc93TYIOOeNIR-Vms_4tWmPB4ASVUuLCBSXhymm58hAC1Cvyi5v9G4JZ505GjbOcdGda1suT0OIDnrPVdPeRODI8MLm3DAqI1FY19x40KVC45pu1o72irFkxIXnLebDfONVNrs/s1600/cogs+lod.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="314" data-original-width="858" height="146" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVptBWJVc93TYIOOeNIR-Vms_4tWmPB4ASVUuLCBSXhymm58hAC1Cvyi5v9G4JZ505GjbOcdGda1suT0OIDnrPVdPeRODI8MLm3DAqI1FY19x40KVC45pu1o72irFkxIXnLebDfONVNrs/s400/cogs+lod.PNG" width="400" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">But it results in an error when used to calculate the percent to Sales</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2uIYpoqzTmMbXbdtHRsifMD8Or8Ev9tVein_WPmYjC5ks9yyXDBWQg60caBdl0rNA66iuh6SA7ssNdSugU_XxLsEqJC4rEYE_PpjgekEx0ypYAps-_zDhaXO3nnZwobWaXmXLua2XyhM/s1600/LOD+error+message.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2uIYpoqzTmMbXbdtHRsifMD8Or8Ev9tVein_WPmYjC5ks9yyXDBWQg60caBdl0rNA66iuh6SA7ssNdSugU_XxLsEqJC4rEYE_PpjgekEx0ypYAps-_zDhaXO3nnZwobWaXmXLua2XyhM/s640/LOD+error+message.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">LODs create a virtual layer in you data set that is at a different level than the data itself BUT they are not an aggregate. To correct the error aggregate the LOD</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ4a-UQe8M_X8ciGRQ2MwcVnbJKZcPX3V3-eUjQQcI2KSuEKUXa8ReXwT3cEHb6meBVQjHZPuiMeOFRDre52mbJqXYMhQNERu2rD-ShNreXVcXr3r_om_qi_qXLxTpVRFWWMP9mtRbDuQ/s1600/corrected+lod.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="319" data-original-width="595" height="171" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQ4a-UQe8M_X8ciGRQ2MwcVnbJKZcPX3V3-eUjQQcI2KSuEKUXa8ReXwT3cEHb6meBVQjHZPuiMeOFRDre52mbJqXYMhQNERu2rD-ShNreXVcXr3r_om_qi_qXLxTpVRFWWMP9mtRbDuQ/s320/corrected+lod.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>5 Value at Max Date</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">A common question is to find the value on the last date - there are 2 ways - My preferred is using an LOD to find the last date in the data for each sub-category</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl5KjgwFYBGflkEoXnrKuhThiGIH8QB7wV0315kBSdnFEJLiQExJl0Lgz60QSsTXMI8Ut96-sW7ELRfWLlp0NbeZT1mpKy_GAMBmVMq66nwFRNck1Ev4rufxQtZDwGQQPXqOcu1gXT8XQ/s1600/last+dat+by+sub+lod.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="186" data-original-width="526" height="141" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl5KjgwFYBGflkEoXnrKuhThiGIH8QB7wV0315kBSdnFEJLiQExJl0Lgz60QSsTXMI8Ut96-sW7ELRfWLlp0NbeZT1mpKy_GAMBmVMq66nwFRNck1Ev4rufxQtZDwGQQPXqOcu1gXT8XQ/s400/last+dat+by+sub+lod.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then the sales value on that date is </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho7vQPULe3TeNoOPer11uhyphenhyphenZw3pRDIvDjC9w99WXAqLNnQQ__OneeDDPYRsKW4E5SDOdtfUd_1Xe3HOyvqUwVBCJkzJloPdIBa5G0utL9j1gagQU5KCHdoE5uoj3nsqJZtJLFfODvc6IY/s1600/max+date+example.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEho7vQPULe3TeNoOPer11uhyphenhyphenZw3pRDIvDjC9w99WXAqLNnQQ__OneeDDPYRsKW4E5SDOdtfUd_1Xe3HOyvqUwVBCJkzJloPdIBa5G0utL9j1gagQU5KCHdoE5uoj3nsqJZtJLFfODvc6IY/s640/max+date+example.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">But it returns and error because the Sales are aggregated but neither the order date nor the LOD are - so a solution would be to aggregate the date and the LOD - here I used Min </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn9z0vaIklcsP21UffS48Ex6rowBUtJEJlxCla-OZPVSmtROUn5tjsQRl_oiKoeRdWhrAq4Dm36_eYFdyJ6R19Zvfmmkj2TPqKZq23_xF0K3zXwcW1zMO0k5SXwMEVZY7rVUWdz7unQJk/s1600/correct+max+date+calcualtion.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="318" data-original-width="1206" height="168" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjn9z0vaIklcsP21UffS48Ex6rowBUtJEJlxCla-OZPVSmtROUn5tjsQRl_oiKoeRdWhrAq4Dm36_eYFdyJ6R19Zvfmmkj2TPqKZq23_xF0K3zXwcW1zMO0k5SXwMEVZY7rVUWdz7unQJk/s640/correct+max+date+calcualtion.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">An alternative would be to use a table calculation (here Last()) but it also returns an error</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLKL_rb0LnaH5Uqn1TYQmNH96mRce2GG_4aPwH5Beb2pyfeCtwU8yY6qWeP297fPJ4vrTsWDm6FDtK1p6HKV4pqeEBkUekviwCFAMjoH67Hi3SlzNFzYj9H-Yc2DPEpM6bcXQC3voiTMU/s1600/last+for+max+date.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLKL_rb0LnaH5Uqn1TYQmNH96mRce2GG_4aPwH5Beb2pyfeCtwU8yY6qWeP297fPJ4vrTsWDm6FDtK1p6HKV4pqeEBkUekviwCFAMjoH67Hi3SlzNFzYj9H-Yc2DPEpM6bcXQC3voiTMU/s640/last+for+max+date.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Which can be resolved by aggregating Sales</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9NUUeByMtBLmyms9TnZWy_EJpFpdtdaJVVYjnGQdLjreyz1Q6zQX5K3lUy_Ves0FuSYiZSmszHDxapOlGet11RaIDMa8oBUOyYVUUY-NgoLu0FCYTsNZceH_7cWe6_W0o3t0OlUVLXC0/s1600/Correct+Last+max+date.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="319" data-original-width="578" height="220" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9NUUeByMtBLmyms9TnZWy_EJpFpdtdaJVVYjnGQdLjreyz1Q6zQX5K3lUy_Ves0FuSYiZSmszHDxapOlGet11RaIDMa8oBUOyYVUUY-NgoLu0FCYTsNZceH_7cWe6_W0o3t0OlUVLXC0/s400/Correct+Last+max+date.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Process to Identify the Aggregate</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">There could be many more examples and still not get to the one you has you stumped - Fortunately there is an easy way to know which of the dimensions or measure in your calculation are aggregated and which are not - </span></div>
<div class="separator" style="clear: both;">
</div>
<div style="text-align: left;">
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">Open the calculation and drag the measures to the Marks card - </span></li>
</ul>
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">IF the show up with an AGG() then they are already aggregates -</span> </li>
</ul>
<ul>
<li><span style="font-family: "arial" , "helvetica" , sans-serif;">If Tableau tried to aggregate them with SUM() then they are not aggregated and you will need to decide which aggregation best fits your analysis</span></li>
</ul>
</div>
<br />
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-voxuHgC3PX_5XEu9t_tSzaX2vMn-8lAhEZGgSBu_RqDjt1qvneqkSwOuhKXDYIN5yRw-ngDzhwLlnQzQ6exh1S7XUBl0-ATY3BRJu5QqL2hlGPag1USEDYcwME308ohGeJn_xhsVAA4/s1600/easy+way+to+find.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-voxuHgC3PX_5XEu9t_tSzaX2vMn-8lAhEZGgSBu_RqDjt1qvneqkSwOuhKXDYIN5yRw-ngDzhwLlnQzQ6exh1S7XUBl0-ATY3BRJu5QqL2hlGPag1USEDYcwME308ohGeJn_xhsVAA4/s640/easy+way+to+find.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Hope this helps - If you have specific examples where you need some help feel free to ping me here or add a post to the Forum</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Enjoy</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Jim</span></div>
www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-30362945531143002232020-01-07T07:49:00.001-06:002020-01-07T07:49:07.178-06:00Put life in your Viz with Set and Parameter actions and Viz in Tooltip<h2 style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Set and Parameter Actions and Viz In Tooltip</span></h2>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Add life to your vizzes and make it easier on the user by using set and parameter actions and viz in tooltip</span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Set Actions</b></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Set actions added to the dashboard are an easy to use alternative to drop down filter. In the dashboard below - the map provides a visual way for users to select the state or regions to be included in the YoY and subcategory Ranking </span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Create a set on State - use select All - the set action will change that later</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihdiLf6qQbLZCDmD_4G3LrFUu3sPz9pL4nK23iZaE_2xwvPjDILfVEe63aIj4ZcdiDx8GNtDpVsSO2OInUG4_ENpuFLnjd-U8eS1u12EXijtMhkQm81Xz_i_8QDVQfIGuW6F_i7dStOB0/s1600/State+set+for+set+action.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="592" data-original-width="455" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihdiLf6qQbLZCDmD_4G3LrFUu3sPz9pL4nK23iZaE_2xwvPjDILfVEe63aIj4ZcdiDx8GNtDpVsSO2OInUG4_ENpuFLnjd-U8eS1u12EXijtMhkQm81Xz_i_8QDVQfIGuW6F_i7dStOB0/s400/State+set+for+set+action.PNG" width="306" /></a></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<br />
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">For use in the YoY and Ranking worksheet you will need a parameter for the end year - (Note for this example I just used full year sales - the approach will work with YTD sales also) </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhV-ZIz5FEsOU2g2CdevaeiqopCzqTfvZ3HOVwBgI_0N6A4G9A1_-N6Hs3nro9lWw6LK16CyC8wsLYs4vEA_zAt3sQA9yP3I6YknLZNWRRCBsE-PnBx1WIsCalP1Ky7NNA2nxoAKKEO1CA/s1600/end+year+parameter.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="491" data-original-width="568" height="276" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhV-ZIz5FEsOU2g2CdevaeiqopCzqTfvZ3HOVwBgI_0N6A4G9A1_-N6Hs3nro9lWw6LK16CyC8wsLYs4vEA_zAt3sQA9yP3I6YknLZNWRRCBsE-PnBx1WIsCalP1Ky7NNA2nxoAKKEO1CA/s320/end+year+parameter.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then LODs for current and prior year sales are needed (Note I included Segment for use in the viz):</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Current Year:</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">{ FIXED [Segment] :sum(</span><span style="font-family: "arial" , "helvetica" , sans-serif;">{ FIXED [Order Date],[Segment],[State]:zn((</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">if year(min([Order Date]))=([3 Enter end year]) and MAX([3 select state for rank])</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">then sum([Sales]) end ))} )}</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Prior Year:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">{ FIXED [Segment] :sum({ FIXED [Order Date],[Segment],[State]:zn((</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">if year(min([Order Date]))=([3 Enter end year]-1) and MAX([3 select state for rank])</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">then sum([Sales]) end ))} )}</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">And YoY sales growth is are:</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">(sum([3 TY Sales])-sum([3 LY Sales]))/sum([3 LY Sales])</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Add an LOD to rank the subcategories</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">{ FIXED year([Order Date]),[Sub-Category],[3 select state for rank]</span><span style="font-family: "arial" , "helvetica" , sans-serif;">:</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">sum(if [3 select state for rank] and year([Order Date])=[3 Enter end year] then </span><span style="font-family: "arial" , "helvetica" , sans-serif;">[Sales]end )}</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">An finally Rank the subcategories using</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">RANK_UNIQUE(sum([3 LOD sales by state for rank]),'desc')</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">and a filter</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">[3 rank states ]<= [3 N for top N]</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Create 3 worksheets:</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">YoY Growth by Market Segments:</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim-RFQvqWXYqv8Fr3yQ-RwOQp5h-G9rl3BU1usbwqTXEl16qZcfHUKv2SqIAALT6ktnQFpzN7Ou8tHlJX4algbP-7Qlk-u9noSnP06qXcrC_rQVIWMjiYSS8v0Y4yy1VV5hkJept25OkE/s1600/YoY+growth+sets.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim-RFQvqWXYqv8Fr3yQ-RwOQp5h-G9rl3BU1usbwqTXEl16qZcfHUKv2SqIAALT6ktnQFpzN7Ou8tHlJX4algbP-7Qlk-u9noSnP06qXcrC_rQVIWMjiYSS8v0Y4yy1VV5hkJept25OkE/s640/YoY+growth+sets.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"> Subcategory Rank</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUOPfZDcgsJyQc2gj-jSLr_hmp6uaevFTtgBKlCKU8Kd2-FQl7rL7wOz04Un_1CWZdV6mSnkirBKfF5GTekfdzXDutlsSezLgcj0e8qsacF_5S_ZITCIbp5u82z0abDnjkxUg4sv86F9U/s1600/rankin+subcat+sets.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUOPfZDcgsJyQc2gj-jSLr_hmp6uaevFTtgBKlCKU8Kd2-FQl7rL7wOz04Un_1CWZdV6mSnkirBKfF5GTekfdzXDutlsSezLgcj0e8qsacF_5S_ZITCIbp5u82z0abDnjkxUg4sv86F9U/s640/rankin+subcat+sets.png" width="640" /></a></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">and the Map is a simple filled map</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1uemMfKPKJFF-ID2rnhVIhOExzLRImT4XSbOT0r_DWfgXmoSWLyjaehPG_y-JfL6w5kdoZDkHc7VLu88RXbGiA55O91wJL_S5vlrjEpVuML4qEqGYskqvczazHiPvy7XE12AH5DvdT-Y/s1600/map+for+sets+actions.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1uemMfKPKJFF-ID2rnhVIhOExzLRImT4XSbOT0r_DWfgXmoSWLyjaehPG_y-JfL6w5kdoZDkHc7VLu88RXbGiA55O91wJL_S5vlrjEpVuML4qEqGYskqvczazHiPvy7XE12AH5DvdT-Y/s640/map+for+sets+actions.png" width="640" /></a></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then bring the together on a dashboard</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEB6oFTuswRQvsWq5MqhNNyc2a3csMTrJ_tRp2es9NpQ0OwFF7BtVEdhMuzJenRzz3aNOqJbKHS_C0GZcDCY8VFWZ9yf5Z6X-JRO_BpebkdBp_UsxB-RbieRsamjihngAujL-NY_Brd40/s1600/set+action+db.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEB6oFTuswRQvsWq5MqhNNyc2a3csMTrJ_tRp2es9NpQ0OwFF7BtVEdhMuzJenRzz3aNOqJbKHS_C0GZcDCY8VFWZ9yf5Z6X-JRO_BpebkdBp_UsxB-RbieRsamjihngAujL-NY_Brd40/s640/set+action+db.png" width="640" /></a></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Add a set action to the Map to change the State Set based on a visual selection from the dashboard</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3jM7I2MwUxPf-dhapvahkf2si-gvCjxmQQVREdjaPpo0V0qhW9_QK6-sn2FXqfRtqfaF8m5gCyAo0cv0yYcPtlIByAXXRJRphcRkH8Rmbrsi76j8uionhL2NaFdvtpkYLtK7MscxoRoY/s1600/set+action+settings.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3jM7I2MwUxPf-dhapvahkf2si-gvCjxmQQVREdjaPpo0V0qhW9_QK6-sn2FXqfRtqfaF8m5gCyAo0cv0yYcPtlIByAXXRJRphcRkH8Rmbrsi76j8uionhL2NaFdvtpkYLtK7MscxoRoY/s640/set+action+settings.png" width="640" /></a></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">And the User can now select states or regions directly from the map and the YoY growth and subcategory ranking will adjust accordingly - </span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Parameter Actions </b></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Parameter actions work just like set actions except parameters are single valued and allow users to select that value visually from a value picket on the dashboard -</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Using the same model as above add a value picker and a parameter action to change the Select End Date Parameter. You can be more elaborate - I just used a simple square chart on a worksheet to make the Value Picker</span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUqX7OjX6iBen8tbYITPV_2rNFb2i-sIj2c-Kl4Rb3CLCLqsm2YUeyGLBYgAkvhKVg36-nh0IKtgus5aV7sPrdl_PiYf8Q5yKGNWOHhAY4fNiwX4oaJsx5yU2ewFXoT5txOpYLgpUIcKA/s1600/date+value+picker.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="496" data-original-width="692" height="229" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUqX7OjX6iBen8tbYITPV_2rNFb2i-sIj2c-Kl4Rb3CLCLqsm2YUeyGLBYgAkvhKVg36-nh0IKtgus5aV7sPrdl_PiYf8Q5yKGNWOHhAY4fNiwX4oaJsx5yU2ewFXoT5txOpYLgpUIcKA/s320/date+value+picker.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Add the Value Picker and a Parameter action to the dashboard</span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUMoiiQAfy5bof-zJezSiKjz2Q3cDIRAqp7Hoh2nW7ftaulugCcnRYXg4JHYB7_4-f4Hkp2TKefUcmmUOpQhvxgwPyTIGozy6L9Y5KuyiWQzJl4mcqaQTiza0w66coQ5pkWb3eZA1tWEU/s1600/Value+picker+action.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUMoiiQAfy5bof-zJezSiKjz2Q3cDIRAqp7Hoh2nW7ftaulugCcnRYXg4JHYB7_4-f4Hkp2TKefUcmmUOpQhvxgwPyTIGozy6L9Y5KuyiWQzJl4mcqaQTiza0w66coQ5pkWb3eZA1tWEU/s640/Value+picker+action.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;">and you are done: </span></div>
<div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">That's only scratching the surface of using set and parameter actions to replace drop down menus - have some fun with them and see - you can't break anything-</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><b>Viz in Tooltip </b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">When Viz in tooltip was introduced in 10.5, it was interesting but I didn't realize that it was a such game changer - </span></div>
<div>
<br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">If you haven't used them, Viz in tooltip is a function that will bring an image of the filtered results from </span><span style="font-family: "arial" , "helvetica" , sans-serif;">another worksheet into the tool tip when the user hovers or click on a mark. It works like a filter action passing dimension values from the first sheet to the second then returns an image (note: a PNG that is not interactive) to the tooltip. </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Lets see how it works</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">Create 2 sheets - the first a simple sales by category bar chart</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEOY8ebH4Vkyis5KWEjI28-ipquuL0TF6Q0Z82JA2f_TM0M3oxxAspfsi5yGBz3_umzRK8pxbC_o0GsJiYZnTJH9BtHUTtU7fcdV6pPR4aYQjwh1LdXNXgcsx29w1EDhvyeJg2yolZkxw/s1600/basic+vit+sheet+1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="468" data-original-width="1600" height="186" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEOY8ebH4Vkyis5KWEjI28-ipquuL0TF6Q0Z82JA2f_TM0M3oxxAspfsi5yGBz3_umzRK8pxbC_o0GsJiYZnTJH9BtHUTtU7fcdV6pPR4aYQjwh1LdXNXgcsx29w1EDhvyeJg2yolZkxw/s640/basic+vit+sheet+1.PNG" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">and a profit map </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwMMj9X4BocXTKdqnDmWo8ss77pd_hW6-D_QzaQ50xOBu4YUPmxj7bb9Q6QZifo7A-EwvlxxSJrSBocmDhe6CIHYSHwQVfkB5w_mfNNgaZvnJf70bajN7-LL9lLGPJSgvLHxbqiYSQlDc/s1600/profit+map.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="837" data-original-width="1600" height="334" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwMMj9X4BocXTKdqnDmWo8ss77pd_hW6-D_QzaQ50xOBu4YUPmxj7bb9Q6QZifo7A-EwvlxxSJrSBocmDhe6CIHYSHwQVfkB5w_mfNNgaZvnJf70bajN7-LL9lLGPJSgvLHxbqiYSQlDc/s640/profit+map.PNG" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">The goal is to show the filtered profit map when hovering over a segment on the bar chart. Open the tootip tile, then select Insert, then Sheet - then select the sheet you want </span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgigycjogfnKfIb8T7iQ5hEftHwfbMoChhRn_YGBxBlqU3h9NIxoRVAy0UFLwuymGXreCSaUcTSV8jj-wgZ6LCm6pSXBP-sJQbrqbyAIck6LaDJ7GEKZLZHReXhbk3521UEczD4FPDj81s/s1600/vit+sheet+selector+set+up.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgigycjogfnKfIb8T7iQ5hEftHwfbMoChhRn_YGBxBlqU3h9NIxoRVAy0UFLwuymGXreCSaUcTSV8jj-wgZ6LCm6pSXBP-sJQbrqbyAIck6LaDJ7GEKZLZHReXhbk3521UEczD4FPDj81s/s640/vit+sheet+selector+set+up.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">And it returns this</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0KJcaUQF0x-KPBB755gpIyKZxefLqZeK0h0-sgMtcSmpZDTcvF7SAiJkRA_nb5kVNze2WhOv6PMLiMzl6o8PUUkQT-Dh8HvPF7ij_O-pM_rgfsB_YfhvmTWK_3w4y-dlGU7Zs4pK47sQ/s1600/2019technology.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0KJcaUQF0x-KPBB755gpIyKZxefLqZeK0h0-sgMtcSmpZDTcvF7SAiJkRA_nb5kVNze2WhOv6PMLiMzl6o8PUUkQT-Dh8HvPF7ij_O-pM_rgfsB_YfhvmTWK_3w4y-dlGU7Zs4pK47sQ/s640/2019technology.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Let's see what is going on - when you set up the tootip, Tableau first added a text string into the tooltip</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY5Op3sosIzD_UetsNQSbmPouzR080LGJfUPq2EjOuxTK26M4_GlEsXqbdeH0bAKRQhka6oWizKPm56cQYneZn9SOlbZVsG2aFXu_ZJ-jOvmgBdGrv500mppPhGxv8qZqI_slROS-VGtA/s1600/vit+text+filter.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="415" data-original-width="1214" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY5Op3sosIzD_UetsNQSbmPouzR080LGJfUPq2EjOuxTK26M4_GlEsXqbdeH0bAKRQhka6oWizKPm56cQYneZn9SOlbZVsG2aFXu_ZJ-jOvmgBdGrv500mppPhGxv8qZqI_slROS-VGtA/s640/vit+text+filter.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The sheet name is in quotations, the max width and height are the size of the image in the tool - you can overwrite the value to resize the image as needed and the dimensions to be filtered on the second sheet - Here All Dimensions from the first sheet are applied to the second sheet (Map) before the image is returned - You specify field you want filtered as shown</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfrAKBoIJEbCwtVyYXlI3BQgtpPlWPylphG22qa0sRYaSsYOZg8Uk-b_BVr4lQb31vPjfPDsfrYk4J7dcnGzPb8jKjwH9pW7xRhX4OCZMEDbiMxhvJFNEChB7eZgXGc_53dh5Ojltn0ZA/s1600/ttip+filter+change.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="413" data-original-width="1206" height="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfrAKBoIJEbCwtVyYXlI3BQgtpPlWPylphG22qa0sRYaSsYOZg8Uk-b_BVr4lQb31vPjfPDsfrYk4J7dcnGzPb8jKjwH9pW7xRhX4OCZMEDbiMxhvJFNEChB7eZgXGc_53dh5Ojltn0ZA/s640/ttip+filter+change.PNG" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Tableau also creates an action filter on the second sheet (Map) based on the filters passed</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0oqw5-lpyYMnaE26Sm_COsGPZLd4fK5CnExcbqi9bJ-PVCDuo7pfiypUdGRuSd9rIakOT90stqRb_TYhz-TXl2O_neSxkiLyCMSLEyy_3wU3We-CaMWbYQM0YWhP0V72bMddPfYxBsRk/s1600/tt+action+filter.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="518" data-original-width="596" height="347" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0oqw5-lpyYMnaE26Sm_COsGPZLd4fK5CnExcbqi9bJ-PVCDuo7pfiypUdGRuSd9rIakOT90stqRb_TYhz-TXl2O_neSxkiLyCMSLEyy_3wU3We-CaMWbYQM0YWhP0V72bMddPfYxBsRk/s400/tt+action+filter.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">That was easy - I've used Viz in tooltip as shown, to bring back the next lower level data from a hierarchy and like a lookup function to bring back specific information on a specific item from a long detailed text table (only the detail table is ugly but I am the only one who sees it - the user just sees the filtered data)</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">This year at TC19 there was a presentation that took Viz in Tooltip to a totally different level. If you weren't fortunate enough to see Jade Le Van's presentation live, see the recording at </span><a href="https://tc19.tableau.com/learn/sessions/next-level-viz-tooltip#recording">https://tc19.tableau.com/learn/sessions/next-level-viz-tooltip#recording</a> - <span style="font-family: "arial" , "helvetica" , sans-serif;">It is an hour well spent.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The 2 examples that follow were derived from her presentation - Only hope to do them justice </span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">First - the "Dashboard in Tooltip" - is not literally copy a dashboard in the tooltip but building one from several worksheets. </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Three worksheets - Sales, Top N and Sales Growth are going go be added ion a single tooltip</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7EMPKvIisKqrhk1-ztiN3B9b318iGcV6D3VqNfWC6OBtZQ6a6jcVwzMCG4mDOM_qseLS3KuOIpgLQokBhq_0h7V21gmwuikrscThUPKCxD8LV1MljSPeI8G3CnMsGn5CaKlqAvW1cH7E/s1600/dashboard+in+tt.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7EMPKvIisKqrhk1-ztiN3B9b318iGcV6D3VqNfWC6OBtZQ6a6jcVwzMCG4mDOM_qseLS3KuOIpgLQokBhq_0h7V21gmwuikrscThUPKCxD8LV1MljSPeI8G3CnMsGn5CaKlqAvW1cH7E/s640/dashboard+in+tt.png" width="640" /></a></span></div>
<br />
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The 3 worksheets are inserted in the tooltip as before - a blank sheet is added to draw a line to separate the views (you will to copy and paste the text)</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAAfmjZ1RapGE0j5s2wtqTx5VxcUs-1WD2awn4BaTiHL9ckcA9F0DTm_Bzi2cKGxlyzN4xEKsYE2X9KUZ6bgeWVNOWy9ewe42ril8ZF4NZZQ4-49t8j-zq9obKOrwekfBLwwZI7W1e7Dc/s1600/db+in+tt++detail.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAAfmjZ1RapGE0j5s2wtqTx5VxcUs-1WD2awn4BaTiHL9ckcA9F0DTm_Bzi2cKGxlyzN4xEKsYE2X9KUZ6bgeWVNOWy9ewe42ril8ZF4NZZQ4-49t8j-zq9obKOrwekfBLwwZI7W1e7Dc/s640/db+in+tt++detail.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Hovering over a state applies filters to 3 worksheet and brings the results to the tooltip -</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div style="text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"></span></div>
<br />
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The last example shows how to see one view in the tooltip on hover but something entirely different when the marked is "clicked" - it is requires several calculations and filters </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Hover returns this</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhM9bNpoRuEjOXp2LLl6n1-xO7JoUGqjUAmXsH2ZYCQfIl7sO793R5D4pOA3bYK7F2IWJetwKTyp1rrb3imdl2tqSYF6_ppsYK8zApm_t3_aNACoBFuIAXedenZsu5lE3fD1NzXB3prXgY/s1600/dual+hover+result.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhM9bNpoRuEjOXp2LLl6n1-xO7JoUGqjUAmXsH2ZYCQfIl7sO793R5D4pOA3bYK7F2IWJetwKTyp1rrb3imdl2tqSYF6_ppsYK8zApm_t3_aNACoBFuIAXedenZsu5lE3fD1NzXB3prXgY/s400/dual+hover+result.png" width="400" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Selecting a state with a click returns this:</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH-XBHOuwdrdRhaZi4oWIcHd9n6Gzk6MZ6vWxn645TW23tcD90xhBp9pGqwgFsFL5Lc8IYhhcVnRdvCocNjcE38BWmFhQwnAUr1rkkx8k-pM-9YlH0pxgEv3mbfqK4GdzF3uNywfggoA/s1600/dual+click+result.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH-XBHOuwdrdRhaZi4oWIcHd9n6Gzk6MZ6vWxn645TW23tcD90xhBp9pGqwgFsFL5Lc8IYhhcVnRdvCocNjcE38BWmFhQwnAUr1rkkx8k-pM-9YlH0pxgEv3mbfqK4GdzF3uNywfggoA/s400/dual+click+result.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Hover does not select a state so the count of all states in the view is 49 (Sorry Alaska). Selecting a state with a click reduces the number to 1 - so we can use a distinct count of states across the view (Window_count) to determine the view we want to see</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">If the Boolean below is True - we want to see the Pie Chart - if False we want the Line Chart</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Window_sum(countd([State]))=1</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Tooltips don't accept calculations - but this will "Sheet Swap" based on the state count</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">CASE [1 window sum countd state tf] </span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">when TRUE then '<Sheet name="percent total pie" maxwidth="300" maxheight="300" filter="<All Fields>">'</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">when FALSE then '<Sheet name="annual profit" maxwidth="500" maxheight="500" filter="<All Fields>">'</span><span style="font-family: "arial" , "helvetica" , sans-serif;">end</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Just need one more thing - hovering does not select a single state - there are still 49 states in the view. We need to pass a single state to the Annual Profit sheet - for that we need a set and set action </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Create a set</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfQQFyuW54wetmdoek_d53Ox3JQarFFkFUMGhlb-UOf2nSFX6U3Rfdp4Gz1yFL0YUTuElF2T7GqHUbyNlIyHHz3bzg-YeIPdcVMgoflLXmGkECCHVNXHx8EPFLFd2eyRhzs9Dmon9v4gE/s1600/dual+state+set.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="593" data-original-width="454" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfQQFyuW54wetmdoek_d53Ox3JQarFFkFUMGhlb-UOf2nSFX6U3Rfdp4Gz1yFL0YUTuElF2T7GqHUbyNlIyHHz3bzg-YeIPdcVMgoflLXmGkECCHVNXHx8EPFLFd2eyRhzs9Dmon9v4gE/s400/dual+state+set.PNG" width="305" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">and a set action</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi14N7Du7imMZPN7DiGsfy2hRjHM3MJtPP8lVhpoHr6lQQxk8UzQw-Y94tFep27fX1bF6TyAL9N0gl1r7YVHXIYkpaVbGLvzRBi_79gd7Eo0t01cSTHVcRoXBdLozriQn4L2qc7IVx4NIw/s1600/dual+set+action.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi14N7Du7imMZPN7DiGsfy2hRjHM3MJtPP8lVhpoHr6lQQxk8UzQw-Y94tFep27fX1bF6TyAL9N0gl1r7YVHXIYkpaVbGLvzRBi_79gd7Eo0t01cSTHVcRoXBdLozriQn4L2qc7IVx4NIw/s640/dual+set+action.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Then create the viz</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDRrhoEu3McPfVyaIQP1yN2FIjzgzX7U34wCCe55h4CDo7-biqw7pOLIL_Q645N14pH4z67d1DsjJomS1NKyrJpIFJ8a5arMxxONqkxnOY2WYoSH35JSK2JV_AdjcgBMtqmpLWh39X0CU/s1600/add+sheet+swap+to+tt.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDRrhoEu3McPfVyaIQP1yN2FIjzgzX7U34wCCe55h4CDo7-biqw7pOLIL_Q645N14pH4z67d1DsjJomS1NKyrJpIFJ8a5arMxxONqkxnOY2WYoSH35JSK2JV_AdjcgBMtqmpLWh39X0CU/s640/add+sheet+swap+to+tt.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">On the Profit sheet add a set action filter</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgX2jtQsBPidne1P-C3zQIb3LbfIhPH7iA35tB1R3bojbKBL30GkdGDjT37UPNHPSgeT3-sq0NX93REgTAMzpNKl37gHi92EjdMqdZihh3x1Ojmoy9z3fjLigohJsTZ_qJ7Cy1rAnnCceo/s1600/dual+profit+sheet+filter.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgX2jtQsBPidne1P-C3zQIb3LbfIhPH7iA35tB1R3bojbKBL30GkdGDjT37UPNHPSgeT3-sq0NX93REgTAMzpNKl37gHi92EjdMqdZihh3x1Ojmoy9z3fjLigohJsTZ_qJ7Cy1rAnnCceo/s640/dual+profit+sheet+filter.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">On the Map apply the click action to the Pie chart only</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFO-TqeOtrdysFAT9s-XkrVCf_4aikikY5yWSSelnWMb_a8o4gvFN39_Nl6kuh2oQFQnQBEWI36o_tQtxcIshHyPsuTWCZk3FbLVaPmcBXd5CsgKAWsHKGQaTEBQWpjMfPyjYklupJ1uw/s1600/dual+click+action+filter.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFO-TqeOtrdysFAT9s-XkrVCf_4aikikY5yWSSelnWMb_a8o4gvFN39_Nl6kuh2oQFQnQBEWI36o_tQtxcIshHyPsuTWCZk3FbLVaPmcBXd5CsgKAWsHKGQaTEBQWpjMfPyjYklupJ1uw/s640/dual+click+action+filter.png" width="640" /></a></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span><span style="font-family: "arial" , "helvetica" , sans-serif;">And you are done</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The workbook containing these examples can be found at </span><a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/VITSetandParameteractions-finalextracted/map?publish=yes">https://public.tableau.com/profile/jim.dehner#!/vizhome/VITSetandParameteractions-finalextracted/map?publish=yes</a></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Fee free to download it an use it as a model</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Enjoy</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Jim</span></div>
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span></div>
www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-46026511769107403032020-01-03T07:28:00.000-06:002022-01-24T08:54:41.229-06:00Zoom in on Map Point with a Radius <h1 style="text-align: left;"><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1><h2><span face=""arial" , "helvetica" , sans-serif"><blockquote style="border: none; font-size: medium; font-weight: 400; margin: 0px 0px 0px 40px; padding: 0px;"></blockquote><p style="font-size: medium; font-weight: 400;"><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p></span></h2><h2><span face=""arial" , "helvetica" , sans-serif"><br /></span></h2><h2><span face=""arial" , "helvetica" , sans-serif"><br /></span></h2><h2>
<span face=""arial" , "helvetica" , sans-serif">"Zoom In" - to Points on Map</span></h2>
<div align="center">
<br /></div>
<div align="center">
</div>
<span face=""arial" , "helvetica" , sans-serif">Recently there have several Forum post asking how to find all the points that are within a radius of a point and to be able to "zoom in" on the map – something like “I want to identify client locations are within 20 miles of each of our 5 office locations of out plant locations” - </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZZko6aMKF39XBZq0CUItsbk8WRO0Y7cFdnjZz_ea7w3nXhl76NrK8bx4ajDkFMkMgf0vWqhd2R6kTqtcvaqMtzJdYLTQ7cfV4dTmI2HsYJSmptwXPS-j-HTdFqBmNqJxHrmrxeheJOSw/s1600/landing+page.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="852" data-original-width="1600" height="340" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZZko6aMKF39XBZq0CUItsbk8WRO0Y7cFdnjZz_ea7w3nXhl76NrK8bx4ajDkFMkMgf0vWqhd2R6kTqtcvaqMtzJdYLTQ7cfV4dTmI2HsYJSmptwXPS-j-HTdFqBmNqJxHrmrxeheJOSw/s640/landing+page.PNG" width="640" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"> </span><br />
<span face=""arial" , "helvetica" , sans-serif">Not an un-common question – and very solvable with Tableau - but being able to "Zoom in" requires a bit of a hack </span><br />
<div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<span face=""arial" , "helvetica" , sans-serif">Like a lot of solutions in Tableau, you need to think backwards . First we need to determine the distance from each office to each client location in the data – Then apply a filter that eliminates the points a greater distance away. Not difficult but a lot of data</span><br />
<div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<span face=""arial" , "helvetica" , sans-serif"><b>Step 1 – Shape the Data</b></span><br />
<div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<span face=""arial" , "helvetica" , sans-serif">You need to have the longitude and latitude of each office and each client location – sorry you won’t be able to use the Tableau generated longs and lats in calculations, so they need to be loaded with the data - <b>keep the files separate</b> - one for the office and one for the client locations.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">To get the solution we need to determine the distance from each office location to every client site and will require connecting the files together with a </span><span face=""arial" , "helvetica" , sans-serif">Cartesian join</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTLTdDcj-YltbYgU9qSxVOj8szE0Rvf31M1xUprS1gQNjcKPs6I_XJxSGwbR0obvHgZ6h_bIrJ-r4TSxhb0irWrtVB5-crs3WXB1E8GT7MYXuIIXrenSAZuenu4DOFgGbEqKJGpfyog04/s1600/cartesian+join.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="323" data-original-width="641" height="201" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTLTdDcj-YltbYgU9qSxVOj8szE0Rvf31M1xUprS1gQNjcKPs6I_XJxSGwbR0obvHgZ6h_bIrJ-r4TSxhb0irWrtVB5-crs3WXB1E8GT7MYXuIIXrenSAZuenu4DOFgGbEqKJGpfyog04/s400/cartesian+join.PNG" width="400" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"> </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The join expands the data set with a separate row for each client location / office site combination</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3dO0zMqaRXHG2LXV4WNerMVAGNgviP09QWoycRdrm6aVG6XjCLn4rDCjaJeRO-hvpJn9X4WFBM5WP3Cm-Rpe59h6Im3EMy9DagQEeUVV2YjfpR6gKHgeUXfSIym_W_o5-VD1e4iNkA1E/s1600/after+join+data.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="582" data-original-width="1533" height="242" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3dO0zMqaRXHG2LXV4WNerMVAGNgviP09QWoycRdrm6aVG6XjCLn4rDCjaJeRO-hvpJn9X4WFBM5WP3Cm-Rpe59h6Im3EMy9DagQEeUVV2YjfpR6gKHgeUXfSIym_W_o5-VD1e4iNkA1E/s640/after+join+data.PNG" width="640" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><b><br />Step 2 – Determine the distance from the office to each client</b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"></span><br />
<span face=""arial" , "helvetica" , sans-serif">I’ve used an LOD that looks at each Office location and determines the distance to every Client location </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<br />
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif">{ FIXED [Client Loc ID],[Office Loc ID] :avg(</span><span face=""arial" , "helvetica" , sans-serif">3959 * ACOS(</span></div>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"> SIN(RADIANS([Client Lat])) * SIN(RADIANS(([Office Lat]))) +</span></div>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"> COS(RADIANS([Client Lat])) * COS(RADIANS(([Office Lat]))) *</span></div>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"> COS(RADIANS(([Office Long]))-RADIANS([Client Long]))</span><span face=""arial" , "helvetica" , sans-serif">) )}</span></div>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><span style="font-size: x-small;">Note: I used the explicit formula rather than the Distance spatial function added in version 2019 - </span></span></div>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: center;">
<br /></div>
<span face=""arial" , "helvetica" , sans-serif">The fixed LOD can be read in words as : for</span><span face=""arial" , "helvetica" , sans-serif"> each combination of the office and client location calculate the “as the crow files distance” using a complex trig formula -- </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /><b>Step 3 Create a Parameter to enter the radius and a filter based on the parameter</b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span><span face=""arial" , "helvetica" , sans-serif">I used a floating point parameter and used a range up to 60 miles with steps of 10 miles – you can use whatever fits your analysis</span><br />
<div style="color: #666666;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkG0VliydNhSgRfa5YgCWdXzAkijSjlvLISvyycb7DBpBF9yVMh-KMCIXiHRSq4C9jEE8qPmYSVZ2wQrk81tFLnhrFlxw3HQOvixB9_IrFsWsM9Qu-aVK1wkguvsmlwKsWMwNrLIQXxY4/s1600/parameter+set+up.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="367" data-original-width="556" height="263" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkG0VliydNhSgRfa5YgCWdXzAkijSjlvLISvyycb7DBpBF9yVMh-KMCIXiHRSq4C9jEE8qPmYSVZ2wQrk81tFLnhrFlxw3HQOvixB9_IrFsWsM9Qu-aVK1wkguvsmlwKsWMwNrLIQXxY4/s400/parameter+set+up.PNG" width="400" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="color: #666666;">
<br /></div>
<br />
<span face=""arial" , "helvetica" , sans-serif">Then add a simple filter that limits the distance between the city center to the value in the parameter – place it on the filter shelf and set to TRUE</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<br />
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"> [Distance Office to Client]<= [Enter Radius]</span></div>
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span><span face=""arial" , "helvetica" , sans-serif"><b>Step 4 - Create the Map</b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span><span face=""arial" , "helvetica" , sans-serif">The Viz is a dual axis map - one layer contains the Client locations the other the Office sites</span><br />
<span face=""arial" , "helvetica" , sans-serif">Filters are added on the Office site location and the Boolean distance filter. I made the Office locations stars - could be any shape - and I use the State dimension to vary the color of the client locations</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx0tu5K8CdW5FJhouZ9EXOSVUqF9cidjH2YU5kZloIQlYI-Q8dr7ELH3ifspo5SBpU4mcJHh4fIlWqUHxFbbvB8uFhDdusQp6qAvidoSlmaOLh-MDhICeTR87opSH1iAa364juFPmb1us/s1600/map+worksheet.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx0tu5K8CdW5FJhouZ9EXOSVUqF9cidjH2YU5kZloIQlYI-Q8dr7ELH3ifspo5SBpU4mcJHh4fIlWqUHxFbbvB8uFhDdusQp6qAvidoSlmaOLh-MDhICeTR87opSH1iAa364juFPmb1us/s640/map+worksheet.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">Convert the map to Dual Axis then go to the Map button on the top ribbon, open and select Map Layers - in the box that opens you will be able to select the style and the layers you want to see</span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7-jSeKVmYcAobl6rRgoyYtPZxYjnSz83qMNvj5-SNpj_-Yrx660Guo5ROpg9uZ8Hf-iD4Yw06X6e6Kh9Ez1T6AxyT_s5pSDkTF1eUm5mjzdU78eph8785KaH1q5PO6NFpIyZwReiY40s/s1600/dual+axis+map.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7-jSeKVmYcAobl6rRgoyYtPZxYjnSz83qMNvj5-SNpj_-Yrx660Guo5ROpg9uZ8Hf-iD4Yw06X6e6Kh9Ez1T6AxyT_s5pSDkTF1eUm5mjzdU78eph8785KaH1q5PO6NFpIyZwReiY40s/s640/dual+axis+map.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><b>Step 5 - the Zoom feature</b></span></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Finally the Zoom feature is controlled by the radius - the smaller the radius the more the user "Zooms" in and conversely larger radii will "Zoom Out" BUT you MUST UNPIN the map and UNSELECT the Pan and Zoom on the Map Options to avoid the map being locked at a zoom level and office location</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTlExu2_QfC2txLycZa29pnPYnrvrUX_-nQo9VB24NLjml_QFtkAHwmB3_GG2kulgy5xVV1Lles54AqsY64z94KirNndOacRFUm4pat7ahbU9uGayVYY8xXTN9AIAnfLsKiGTb1AWyKP8/s1600/pan+or+zoom.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTlExu2_QfC2txLycZa29pnPYnrvrUX_-nQo9VB24NLjml_QFtkAHwmB3_GG2kulgy5xVV1Lles54AqsY64z94KirNndOacRFUm4pat7ahbU9uGayVYY8xXTN9AIAnfLsKiGTb1AWyKP8/s640/pan+or+zoom.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">Bring the map and filter and parameter to a dashboard and annotate as needed</span></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJ_TODQfD8V87Tz5NCW8CUUSVxTzKrs0MiMU8BB06zffpAe22zrO1zawXNIoZQFOSIibWHNoFtIi0PJpOof40G3hwUlivS6G-q1_o58UQu5AnduguVjHqjwF7bV-eotaG-MgH4iOZQpEY/s1600/end+results.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJ_TODQfD8V87Tz5NCW8CUUSVxTzKrs0MiMU8BB06zffpAe22zrO1zawXNIoZQFOSIibWHNoFtIi0PJpOof40G3hwUlivS6G-q1_o58UQu5AnduguVjHqjwF7bV-eotaG-MgH4iOZQpEY/s640/end+results.png" width="640" /></a></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<span face=""arial" , "helvetica" , sans-serif">I have a similar map on my Tableau Public site at </span><br />
<span face=""arial" , "helvetica" , sans-serif"><a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/Findclientswithinradius_v10_5/Interactivemap">https://public.tableau.com/profile/jim.dehner#!/vizhome/Findclientswithinradius_v10_5/Interactivemap</a></span><br />
<br />
<span face=""arial" , "helvetica" , sans-serif">Feel free to download it (or any other file on the site) to use as a model </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Jim</span><br />
<br />
<div style="color: #666666;">
</div>
<br />
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: "Times New Roman"; font-size: medium; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin: 0px; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<br /></div>
www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0tag:blogger.com,1999:blog-8795285084334483381.post-86850411130649376502019-12-31T13:10:00.004-06:002022-01-24T08:54:53.081-06:00How-To Create a Normal Distribution Chart<blockquote style="border: none; margin: 0px 0px 0px 40px; padding: 0px;"><h1><span style="font-family: arial;">My blog has moved to jimdehner.com </span></h1></blockquote><p><span style="font-family: arial;">Thank you for all the support over the past 2 years - I recently updated my blog to make it easier to read, improve the rendering of images and tie back to video presentations that are associated with the content - Check it out at <a href="https://jimdehner.com/" target="_blank">Jim's new blog</a></span> - </p>
<br />
<br />
<div align="center">
<span style="font-size: 14pt;"><span face=""arial" , "helvetica" , sans-serif"><b>How-To Create a Normal Distribution Chart</b></span></span></div>
<div align="center">
<span style="font-size: 14pt;"><span face=""arial" , "helvetica" , sans-serif"><br /></span></span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif">Occasionally there are Forum questions on creating normal distribution curves. </span></div>
<div style="text-align: left;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTx7SVgVoR2u7VayuVUFn24O-HDr6hy7s6-bM69UQANCN7UEtT13wMxmxKxWl7wClqaIpFhw_L-DuIT7naKk1FLcc5JYG6_T7lAKwc0-0bqZYEdy-cViLjr_erkfGKUg4Dl1ujL9Qzm1E/s1600/landing+page.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="809" data-original-width="1010" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTx7SVgVoR2u7VayuVUFn24O-HDr6hy7s6-bM69UQANCN7UEtT13wMxmxKxWl7wClqaIpFhw_L-DuIT7naKk1FLcc5JYG6_T7lAKwc0-0bqZYEdy-cViLjr_erkfGKUg4Dl1ujL9Qzm1E/s400/landing+page.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<span face=""arial" , "helvetica" , sans-serif">The approach here relies heavily on the concept of data densification develop and refined by Bora Beran, Joe Mako, Jonathan Drummey, Ken Flerlage and others – Readers are encouraged to review their works on creating shapes and charts using the process.</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">This is a straightforward application of the normal distribution formula:</span><br />
<span face=""arial" , "helvetica" , sans-serif"> </span><br />
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><b>Y= (1/[σ*sqrt(2π])*e</b></span></div>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><b>Where σ= Standard Deviation</b></span></div>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><b> µ=Mean</b></span></div>
<br />
<span face=""arial" , "helvetica" , sans-serif">You may find more elegant approaches – when you do please let me know so we all can benefit</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The data used here is the “Superstore” data set that comes with Tableau desktop – while the data set is detailed down to the transaction level the examples here go to the Year/Category level – the concept can be adapted to any level in the Superstore data set or your own</span><br />
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span><span face=""arial" , "helvetica" , sans-serif"><b>Overview –</b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Tableau does not draw curved lines – so we simulate the familiar smooth bell curve of the normal distribution with a series of straight lines on an X-Y Cartesian coordinate grid. The densification process is used to create intervals on the X-Axis (Sales in these examples). As the number of intervals increases the plot becomes less angular. There is a parameter to adjust the number of intervals – somewhere between 50-100 intervals produces a reasonably smooth curve –play with it using your own data to see what works for you</span><br />
<div style="font-size: 14pt;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div align="center">
<span style="font-size: 14pt;"><span face=""arial" , "helvetica" , sans-serif">– At this point if you have not familiar with Data Densification</span></span></div>
<div align="center">
<span style="font-size: 14pt;"><span face=""arial" , "helvetica" , sans-serif"><br /></span></span></div>
<div align="center">
<span style="font-size: 14pt; font-weight: 600;"><span face=""arial" , "helvetica" , sans-serif">STOP</span></span></div>
<div align="center">
<span style="font-size: 14pt; font-weight: 600;"><span face=""arial" , "helvetica" , sans-serif"><br /></span></span></div>
<br />
<div align="center">
<span style="font-size: 14pt;"><span face=""arial" , "helvetica" , sans-serif">and review one of the resources noted above. </span></span></div>
<div align="center">
<span style="font-size: 14pt;"><span face=""arial" , "helvetica" , sans-serif"><br /></span></span></div>
<span face=""arial" , "helvetica" , sans-serif"><b>Step 1 Prepare the data for densification</b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span><span face=""arial" , "helvetica" , sans-serif"></span>
<span face=""arial" , "helvetica" , sans-serif">Duplicate the data set by creating a union of the data with itself. Tableau will create a Dimension "Table Name" that can be used to distinguish the original data set from the duplicate - in the example the original data set is "Orders" and the duplicate in "Orders1"</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIhvSrx1TadiI4iipaHiJMX3DDd3bDtlffoT7_t8JxJXn0wQ2650_YKtlDk_2B-kef_z2ja0n1Ln4ziUvW_wJ2fWNhSsjnSseA2257OWx4OQ_k6_rx7wcTUoBqEASYICmnL9eVwYnADIE/s1600/copy+data+set.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="622" data-original-width="1191" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIhvSrx1TadiI4iipaHiJMX3DDd3bDtlffoT7_t8JxJXn0wQ2650_YKtlDk_2B-kef_z2ja0n1Ln4ziUvW_wJ2fWNhSsjnSseA2257OWx4OQ_k6_rx7wcTUoBqEASYICmnL9eVwYnADIE/s400/copy+data+set.PNG" width="400" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<span face=""arial" , "helvetica" , sans-serif"></span><br />
<br />
<span face=""arial" , "helvetica" , sans-serif">Next create a calculation to define the ends point needed for the X-values</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><b>Path = if [Table Name]="Orders1" then 1 else [max number of intervals] end</b></span></div>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><br /></span></div>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"> Where [Max number of intervals] is the parameter to vary the x axis spacing</span></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Use the Path formula to create bins –</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiASmGwT3FLpgoosddt68e4QfeQZa_RbAyWsR-T0KYzGgm8ptX2lvh81Vbvt6ELXK3sgnZDPsdRpQS4rwcquH2U7zXueJgYKumYRpHIK1BVMvkz83eF45yrfSJNmzXzpkX4BaNR3ZnStOY/s1600/create+bins.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="756" data-original-width="685" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiASmGwT3FLpgoosddt68e4QfeQZa_RbAyWsR-T0KYzGgm8ptX2lvh81Vbvt6ELXK3sgnZDPsdRpQS4rwcquH2U7zXueJgYKumYRpHIK1BVMvkz83eF45yrfSJNmzXzpkX4BaNR3ZnStOY/s320/create+bins.PNG" width="289" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span face=""arial" , "helvetica" , sans-serif">Set the Bin Size to 1 - it will be the increment on the "X-axis" - <span style="font-size: x-small;">(note I changed the bin name to Padded)</span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJi9ULszg20L7_ZISBUNg1u7vaaLZl259TQFAB_uW-L0OdzgK9nB5aZxZLznpyiUP47zMypIsA8_hgV0Ru3vozmj3laXH-BThwvNE2TrIEr7iLrfMfBZyAg-wJjYdJUHBUiwEpYzW8C7c/s1600/bin+settings.PNG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="229" data-original-width="448" height="163" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJi9ULszg20L7_ZISBUNg1u7vaaLZl259TQFAB_uW-L0OdzgK9nB5aZxZLznpyiUP47zMypIsA8_hgV0Ru3vozmj3laXH-BThwvNE2TrIEr7iLrfMfBZyAg-wJjYdJUHBUiwEpYzW8C7c/s320/bin+settings.PNG" width="320" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"> </span><br />
<span face=""arial" , "helvetica" , sans-serif"></span><br />
<br />
<span face=""arial" , "helvetica" , sans-serif"><b>Step 2 – Create the X-values using the bins to pad the data </b>– <span style="font-size: x-small;">NOTE I used a +- 4 sigma range </span></span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">First, determine the µ and σ values – the average and the standard deviation values in this example on Sales – but we want to be able to vary the results by year and by category</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">For that use an LOD’s to create the needed combinations of year and category and the widow function forces the calculation to be executed in each bin across the viz</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><b>Mu= window_min( avg({ FIXED year([Order Date]),[Category] :avg([Sales]) }) )</b></span></div>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><b><br /></b></span></div>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><b> Sigma= window_min(min({ FIXED year([Order Date]),[Category] :STDEV([Sales]) }) )</b></span></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Where (index()-1) is the bin number (interval) on the x axis</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"> <b>X-value = (-4*[sigma])+([index-1 ]*(8*[sigma]))/window_max(max([Path])) </b></span></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><b>Step 3 – Solve the Normal Distribution formula for Y</b> </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Table calculations are used to determine then Y value at each bin (x-value)</span><br />
<br />
<span face=""arial" , "helvetica" , sans-serif">For clarity there are 2 calculations </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The coefficient = (1/[σ*sqrt(2π])</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"> <b> Coeff= 1/(sqrt(2*pi()*([sigma]^2)))</b></span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The Exponent =</span><br />
<span face=""arial" , "helvetica" , sans-serif"> <b>Exponent = (-((([X value (Sales)])-[mu])^2)/((2*([sigma]^2))) )</b></span><br />
<br />
<span face=""arial" , "helvetica" , sans-serif">And then combined them in a single formula for Y <span style="font-size: x-small;">(note Tableau does not have an <b>"e" </b>function but the EXP() will return the correct value)</span></span><br />
<span face=""arial" , "helvetica" , sans-serif"> </span><br />
<div style="text-align: center;">
<span face=""arial" , "helvetica" , sans-serif"><b>Y= ([coeff]*EXP([exponent]) )</b></span></div>
<br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><b>Step 4 – Create the viz</b> –</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Place the X and Y values on columns and rows then add the Mu and Sigma values to the Detail tile</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7DIjCAjopGUZ_JDw7_xCSH69MRIzeRIgooiZA-R-y2Zr845eF80gEYCdBnfZMopjXs6JaJ9hI1trqni8jMP6wIpamMs8NOTegyG8gZfN-14UliU7ENxo9krb6oRKalLKWM7o5JpOdyHU/s1600/create+db.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7DIjCAjopGUZ_JDw7_xCSH69MRIzeRIgooiZA-R-y2Zr845eF80gEYCdBnfZMopjXs6JaJ9hI1trqni8jMP6wIpamMs8NOTegyG8gZfN-14UliU7ENxo9krb6oRKalLKWM7o5JpOdyHU/s640/create+db.png" width="640" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Then add Padded (the bins) to the viz and set the calculation across the bins (all places)</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYnsuYAME5dZlisBWSByicB4cxYAwU7nRDJW-adGhV8U9uC5mLGN-C7-pbymBRNXJnMKBJFa0BsF-_v8HtxN2zcT9kc7dFjgEDVR-JfbsbBOKyWo6FBgIRg62urkWm2IjtZ-drcWa0COA/s1600/padded.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYnsuYAME5dZlisBWSByicB4cxYAwU7nRDJW-adGhV8U9uC5mLGN-C7-pbymBRNXJnMKBJFa0BsF-_v8HtxN2zcT9kc7dFjgEDVR-JfbsbBOKyWo6FBgIRg62urkWm2IjtZ-drcWa0COA/s640/padded.png" width="640" /></a></div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">You can also make normalized distribution charts using the formula below</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"> </span><span face=""arial" , "helvetica" , sans-serif"><b>x-normalized = ([mu]-[X value (Sales)])/[sigma</b>]</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">and replace the x-value in any of the charts</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUyypIeMn8P-r4lfCImjuDi1cGxSl1pGxt_7yia8lyVPfThHl5rpE2Ck_6tw3iFPcKFdnzu9IGijjvaTcdd6WL2Xovm3siom4kO0CedJlNVPszCL9xDae0rfsr4x7fYRjc3Wiv5VU3SM0/s1600/new+std+dev.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="900" data-original-width="1600" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUyypIeMn8P-r4lfCImjuDi1cGxSl1pGxt_7yia8lyVPfThHl5rpE2Ck_6tw3iFPcKFdnzu9IGijjvaTcdd6WL2Xovm3siom4kO0CedJlNVPszCL9xDae0rfsr4x7fYRjc3Wiv5VU3SM0/s640/new+std+dev.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"> </span><br />
<span face=""arial" , "helvetica" , sans-serif">Finally, I added a parameter and a filter to allow the user to change the number of standard deviations visible in the charts</span><br />
<span face=""arial" , "helvetica" , sans-serif"> </span><br />
<b><span face=""arial" , "helvetica" , sans-serif"> N-Std Dev Filter = [x normalized (Sales)] >= -[enter number of standard deviations] and</span><span face=""arial" , "helvetica" , sans-serif"> </span><span face=""arial" , "helvetica" , sans-serif">[x normalized (Sales)]<=[enter number of standard deviations]</span></b><br />
<br />
<br />
<span face=""arial" , "helvetica" , sans-serif">Place it on the filter shelf – it too is a table calculation set to use Padded – then set to True </span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">The workbook containing these examples and more can be found on my Tableau Public site at </span><a href="https://public.tableau.com/profile/jim.dehner#!/vizhome/Howtocreateanormaldistributionchart_v2018_3/summary">https://public.tableau.com/profile/jim.dehner#!/vizhome/Howtocreateanormaldistributionchart_v2018_3/summary</a><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif">Jim</span><br />
<span face=""arial" , "helvetica" , sans-serif"><br /></span><span face=""arial" , "helvetica" , sans-serif"><br /></span><br />
<br />www.jimdehner.blogspot.comhttp://www.blogger.com/profile/05838262893561670966noreply@blogger.com0