<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" >

<channel><title><![CDATA[NUPANCH - Blog]]></title><link><![CDATA[http://www.nupanch.com/blog]]></link><description><![CDATA[Blog]]></description><pubDate>Mon, 02 Feb 2026 14:21:01 +0530</pubDate><generator>Weebly</generator><item><title><![CDATA[Using Retail Calendar for Period-over-Period Comparisons in Looker]]></title><link><![CDATA[http://www.nupanch.com/blog/using-retail-calendar-for-period-over-period-comparisons-in-looker]]></link><comments><![CDATA[http://www.nupanch.com/blog/using-retail-calendar-for-period-over-period-comparisons-in-looker#comments]]></comments><pubDate>Fri, 13 Dec 2024 09:50:20 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.nupanch.com/blog/using-retail-calendar-for-period-over-period-comparisons-in-looker</guid><description><![CDATA[       Introduction  In this post, we will explore the implementation of Retail Calendars in Looker and delve into the advantages they offer. We will focus on how to leverage these calendars to build scalable Period Over Period (PoP) comparison functionalities. This includes importing retail calendar data into a Looker view, extending the view, and creating new dimensions to enable seamless period-based analysis. We will also cover how to join these calendars to explores, ensuring flexibility in [...] ]]></description><content:encoded><![CDATA[<div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/published/retail-calendar-blog-post.webp?1734083532" alt="Picture" style="width:267;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <h2 class="wsite-content-title" style="text-align:justify;">Introduction</h2>  <div class="paragraph" style="text-align:justify;">In this post, we will explore the implementation of Retail Calendars in Looker and delve into the advantages they offer. We will focus on how to leverage these calendars to build scalable Period Over Period (PoP) comparison functionalities. This includes importing retail calendar data into a Looker view, extending the view, and creating new dimensions to enable seamless period-based analysis. We will also cover how to join these calendars to explores, ensuring flexibility in reporting. Additionally, we will walk through implementation details with code snippets and provide comparison examples to illustrate the impact of these techniques.<br /><br />By the end of this blog, you will have a robust, user-friendly solution to perform powerful period comparisons, such as analyzing a Retail Month against the same month in the previous year.</div>  <div>  <!--BLOG_SUMMARY_END--></div>  <h2 class="wsite-content-title" style="text-align:justify;"><font size="4">What is a Retail Calendar?</font></h2>  <div class="paragraph" style="text-align:justify;">A Retail Calendar is a specialized calendar used in the retail industry to track sales and inventory over specific periods, often aligning with seasonal trends and business cycles. Unlike a standard calendar, retail calendars such as the 4-5-4 calendar are structured to maintain consistent weeks for accurate year-over-year (YoY) comparisons. For a detailed overview, the <a href="https://nrf.com/resources/4-5-4-calendar" target="_blank">NRF website</a> provides an excellent explanation.</div>  <div><div style="height: 20px; overflow: hidden; width: 100%;"></div> <hr class="styled-hr" style="width:100%;"></hr> <div style="height: 20px; overflow: hidden; width: 100%;"></div></div>  <h2 class="wsite-content-title" style="text-align:justify;"><font size="5">&#8203;Implementation: Standard Calendar vs. Retail Calendar</font></h2>  <h2 class="wsite-content-title" style="text-align:justify;"><span style="font-weight:normal"><span style="color:rgb(32, 33, 34); font-weight:700"><font size="4">Standard Calendar in Looker</font></span></span></h2>  <div class="paragraph" style="text-align:justify;">Looker uses a standard calendar by default, based on the Gregorian system. You can customize the starting day of the week (e.g., Sunday or Monday) by including week_start_day: sunday in the model configuration. While this works well for general reporting, it falls short when comparing periods with varying numbers of days or inconsistent week structures.</div>  <h2 class="wsite-content-title" style="text-align:justify;">&#8203;<font size="4">Implementing a Retail Calendar in Looker</font></h2>  <div class="paragraph" style="text-align:justify;">To implement a retail calendar:<ul><li><strong>Create a View</strong>: Start by creating a view containing retail calendar data. This data can be sourced from:<ul><li>A Google Sheet with updated dates.</li><li>SQL queries to generate the necessary calendar structure.</li></ul></li><li>Note that different businesses may adopt other variations, such as a 4-4-5 calendar. One such example can be found here : <a href="https://docs.google.com/spreadsheets/d/1JIVwMOptWsv2JGJrMUHpL6mnVChpjgitzjy0r-4xS_4/edit?gid=0#gid=0" target="_blank">Google Sheet Link</a></li><li><strong>Join the View</strong>: Join the retail calendar view on the date field with the date field of any other view where needed. This ensures the retail calendar&rsquo;s alignment with other datasets in your model.</li></ul></div>  <div><div style="height: 20px; overflow: hidden; width: 100%;"></div> <hr class="styled-hr" style="width:100%;"></hr> <div style="height: 20px; overflow: hidden; width: 100%;"></div></div>  <h2 class="wsite-content-title" style="text-align:justify;"><font size="5">Why Use a Retail Calendar in Looker?</font></h2>  <div class="paragraph" style="text-align:justify;">The primary advantage of using a retail calendar lies in its ability to compare identical periods containing the same number of days, weekends, and holidays. For instance, comparing January of this year with January of last year using the Gregorian calendar can lead to discrepancies due to varying week structures. A retail calendar resolves this issue, ensuring accurate YoY comparisons.<br />If you haven&rsquo;t already, we recommend checking out our <a href="https://www.nupanch.com/blog/how-to-implement-period-over-period-analysis-in-looker" target="_blank">foundational approach</a> to building Period Over Period capabilities in Looker, as this blog builds upon that methodology. Our approach overcomes some of the limitations of Looker&rsquo;s default setup, especially in terms of scalability.</div>  <div><div style="height: 20px; overflow: hidden; width: 100%;"></div> <hr class="styled-hr" style="width:100%;"></hr> <div style="height: 20px; overflow: hidden; width: 100%;"></div></div>  <h2 class="wsite-content-title" style="text-align:justify;"><span style="font-weight:normal"><span style="color:rgb(32, 33, 34); font-weight:700"><font size="4">Example: Integrating Retail Calendars into PoP Analysis</font></span></span></h2>  <div class="paragraph" style="text-align:justify;">For a recent project, we implemented a 4-4-5 retail calendar to meet client-specific needs. Here&rsquo;s how:</div>  <h2 class="wsite-content-title"><font size="4">Import Retail Calendar Data:</font></h2>  <div class="paragraph" style="text-align:justify;"><ul style="color:rgb(129, 129, 129)"><li>Use a Google Sheet (or other sources) containing 4-5-4 calendar dates.</li><li>Sample sheets for 4-5-4 or 4-4-5 retail calendars can be easily found online.</li></ul></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/retail-calendar-view_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <h2 class="wsite-content-title" style="text-align:justify;"><span style="color:rgb(32, 33, 34)"><font size="4">Extend the View:</font></span></h2>  <div class="paragraph" style="text-align:justify;"><ul><li>Create a Period Over Period (PoP) view by extending the retail calendar view.</li><li>This allows predefined analysis periods and breakdowns, which can be scaled across multiple explores, avoiding code replication.</li></ul></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/retail-view-extends_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <h2 class="wsite-content-title" style="text-align:justify;"><span style="color:rgb(32, 33, 34)"><font size="4">Create new Dimensions in the Extended view</font></span></h2>  <div class="paragraph" style="text-align:justify;"><ul><li>&#8203;&#8203;<span><span style="color:rgb(32, 33, 34); font-weight:700">PoP Pivot Dimension&#8203;<br />&#8203;</span></span><span style="color:rgb(129, 129, 129)">&#8203;A pivot dimension consisting of the time periods selected for comparison.</span><span><span style="color:rgb(32, 33, 34); font-weight:700"></span></span>&#8203;<br /></li></ul></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/pop-pivot_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><ul><li><strong><span><span style="font-weight:700"><font color="#2a2a2a">PoP Row Dimension&#8203;<br />&#8203;</font></span></span></strong><span style="color:rgb(129, 129, 129)">&#8203;Date breakdown to be shown in rows for respective comparison.</span><strong><span><span style="font-weight:700"></span></span></strong><span style="color:rgb(129, 129, 129)">&#8203;</span><br /></li></ul></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/pop-row_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><ul><li><strong><font color="#000000">&#8203;&#8203;<span style="font-weight:700">Sort By<br /></span></font></strong><span style="color:rgb(129, 129, 129)">Sort by field&nbsp;ensures that the PoP Pivot and PoP Rows are displayed in logical order.</span><strong><font color="#000000"><span style="font-weight:700"></span></font></strong><br /></li></ul></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/sort-by1_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/sort-by2_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><ul><li><span><span style="font-weight:700"><font color="#000000">Filter Date<br />&#8203;</font></span></span><span style="color:rgb(129, 129, 129)">&#8203;The Filter Date will always have to be filtered with the Analysis Period to ensure dates are filtered according to the Analysis Period selected.</span></li></ul></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/filter-date-update-rm_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><ul><li><span><span style="font-weight:700"><font color="#000000">To-Date</font></span></span><br /></li></ul></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/choose-to-date_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/to-date-retail_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <h2 class="wsite-content-title" style="text-align:justify;"><span style="color:rgb(32, 33, 34)"><font size="4">Join to Explores:</font></span></h2>  <div class="paragraph" style="text-align:justify;">&#8203;Join the PoP and retail calendar views to any required explore. For example, if the explore is named daily_sales, the join relationship will depend on the nature of the daily_sales table.</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/joining-explores_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <h2 class="wsite-content-title"><strong><font size="4">Add Comparisons:</font></strong></h2>  <div class="paragraph">Use these joins to add retail period comparisons to PoP analysis. Examples include:<ul><li>This Retail Month vs. Same Retail Month Last Year.</li><li>This Retail Quarter vs. Same Retail Quarter Last Year.</li></ul></div>  <div class="paragraph">The below screenshots show how all the dimensions work with and without to date.</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/choose-to-date-yes-highlight_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:center;"><em style="color:rgb(129, 129, 129)"><font size="1">The above illustration shows the comparison of This Retail Month vs Same Retail Month Last Year where we use To-Date comparisons</font></em></div>  <span class='imgPusher' style='float:left;height:0px'></span><span style='display: table;width:auto;position:relative;float:left;max-width:100%;;clear:left;margin-top:0px;*margin-top:0px'><a><img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/choose-to-date-no-highlight_orig.jpg" style="margin-top: 10px; margin-bottom: 10px; margin-left: 0px; margin-right: 10px; border-width:0; max-width:100%" alt="Picture" class="galleryImageBorder wsite-image" /></a><span style="display: table-caption; caption-side: bottom; font-size: 90%; margin-top: -10px; margin-bottom: 10px; text-align: center;" class="wsite-caption"></span></span> <div class="paragraph" style="text-align:center;display:block;"><em><font size="1">The above illustration shows the comparison of This Retail Month vs Same Retail Month Last Year where we do not use To-Date comparisons</font></em></div> <hr style="width:100%;clear:both;visibility:hidden;"></hr>  <h2 class="wsite-content-title"><strong><span style="color:rgb(129, 129, 129); font-weight:300"><font size="4">Conclusion</font></span></strong></h2>  <div class="paragraph" style="text-align:justify;">By integrating a retail calendar into Looker, you can significantly enhance your ability to perform accurate period comparisons. This approach not only ensures consistency but also scales seamlessly across multiple datasets and explores. Whether you&rsquo;re working with a 4-5-4 or 4-4-5 calendar, this solution empowers you to make data-driven decisions with precision and ease.<br />Ready to implement this in your Looker instance? Dive in and see how simple it can be to create powerful, scalable period-over-period analyses!&#8203;</div>  <div><div style="height: 20px; overflow: hidden; width: 100%;"></div> <hr class="styled-hr" style="width:100%;"></hr> <div style="height: 20px; overflow: hidden; width: 100%;"></div></div>  <div><div class="wsite-multicol"><div class="wsite-multicol-table-wrap" style="margin:0 -15px;"> 	<table class="wsite-multicol-table"> 		<tbody class="wsite-multicol-tbody"> 			<tr class="wsite-multicol-tr"> 				<td class="wsite-multicol-col" style="width:50%; padding:0 15px;"> 					 						  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0px;margin-right:0px;text-align:left"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/published/squarepic-20210217-18451289.jpg?1740981519" alt="Picture" style="width:135;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <h2 class="blog-author-title"><font size="3">Ashish Masand</font></h2> <p><strong><font size="2">Lead Data Analyst</font></strong></p>   					 				</td>				<td class="wsite-multicol-col" style="width:50%; padding:0 15px;"> 					 						  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0px;margin-right:0px;text-align:left"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/published/profile-pic.jpg?1740981488" alt="Picture" style="width:130;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <h2 class="blog-author-title"><font size="3">Shridhar Patil</font></h2> <p><strong><font size="2">Data Analyst</font></strong></p>   					 				</td>			</tr> 		</tbody> 	</table> </div></div></div>]]></content:encoded></item><item><title><![CDATA[Period-over-Period in Looker: A Quick Guide]]></title><link><![CDATA[http://www.nupanch.com/blog/how-to-implement-period-over-period-analysis-in-looker]]></link><comments><![CDATA[http://www.nupanch.com/blog/how-to-implement-period-over-period-analysis-in-looker#comments]]></comments><pubDate>Mon, 21 Oct 2024 09:07:28 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.nupanch.com/blog/how-to-implement-period-over-period-analysis-in-looker</guid><description><![CDATA[       Introduction&#8203;In this article, we&rsquo;ll walk through how to implement Period Over Period (PoP) comparisons in Looker. While Looker suggests a few approaches for comparing different time periods, we will introduce a customized approach developed by our team at Nupanch. Our approach highlights enhancements that can be made to Looker&rsquo;s suggested methods. This guide includes code snippets and example outputs, so you can easily replicate these techniques in your own Looker instan [...] ]]></description><content:encoded><![CDATA[<div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/editor/dall-e-2024-10-29-18-04-26-a-black-and-white-2d-illustration-in-a-clipboard-style-showing-a-line-chart-comparing-two-different-periods-the-chart-is-clipped-onto-a-clipboard-w.webp?1731665195" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><strong><span><span><font size="4">Introduction<br />&#8203;</font></span></span></strong><span><span>In this article, we&rsquo;ll walk through how to implement Period Over Period (PoP) comparisons in Looker. While Looker suggests a few approaches for comparing different time periods, we will introduce a customized approach developed by our team at Nupanch. Our approach highlights enhancements that can be made to Looker&rsquo;s suggested methods. This guide includes code snippets and example outputs, so you can easily replicate these techniques in your own Looker instance.&nbsp;<br /></span></span></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph" style="text-align:justify;">&#8203;<span><span><strong><font size="4">Understanding Period Over Period Comparisons</font></strong></span></span><br /><span><span>Before diving into the implementation, let&rsquo;s quickly explore why Period Over Period comparisons are so useful.&nbsp;</span></span><span><span>When measuring performance, it&rsquo;s critical to compare current performance against previous periods. Some common comparisons include:</span></span><ul><li><span><span>This year vs. last year</span></span></li><li><span><span>This month vs. last month</span></span></li><li><span><span>This quarter vs. same quarter last year</span></span></li></ul> <span><span>PoP comparisons help you identify trends and patterns, enabling better business decision-making. For instance, you might want to track:</span></span><ul><li><span><span>How your business performed this year compared to last year</span></span></li><li><span><span>Whether you hit your sales targets for this quarter</span></span></li><li><span><span>Business performance for specific periods like Cyber Weekend</span></span></li></ul></div>  <div class="paragraph" style="text-align:justify;"><strong><span><span><font size="4">Looker&rsquo;s Built-in Methods for PoP Analysis</font></span></span></strong><br /><span><span>Looker provides a few built-in methods for performing PoP comparisons:</span></span><ol><li><span><span style="font-weight:700">Any Two Native Timeframes</span><span>: Compare two predefined periods, broken down by days, weeks, or months.</span></span></li><li><span><span style="font-weight:700">Current and Previous Periods</span><span>: Filter for the current period and compare it to the previous year, month, or week.</span></span></li><li><span><span style="font-weight:700">Arbitrary Periods</span><span>: Select any two periods for comparison, typically broken down by days, allowing you to see totals for each period.</span></span></li></ol><span><span>For more details on these methods, check out </span><a href="https://www.googlecloudcommunity.com/gc/Technical-Tips-Tricks/Methods-for-Period-Over-Period-PoP-Analysis-in-Looker/ta-p/587538"><span style="color:rgb(17, 85, 204)">Looker&rsquo;s support article</span></a><span>.</span></span></div>  <div class="paragraph" style="text-align:justify;"><strong><span><span><font size="4">Limitations of Looker&rsquo;s Built-in Methods<br />&#8203;</font></span></span></strong><span><span>While Looker&rsquo;s native methods work well, there are some limitations:</span></span><ul><li><span><span>Hard to scale. The logic can only be used within a single view</span></span></li><li><span><span>Predefined periods may not suit all use cases.</span></span></li><li><span><span>Filtering options are limited, and may not allow for custom periods.</span></span></li><li><span><span>Arbitrary Period comparisons are often restricted to days, limiting flexibility.</span></span></li></ul> <span><span>Because of these limitations, we at Nupanch developed a customized approach tailored to the needs of our clients.</span></span></div>  <div class="paragraph" style="text-align:justify;"><span><span><strong><font size="4">Nupanch&rsquo;s Approach to PoP Analysis in Looker</font></strong></span></span><br /><span><span>Our approach simplifies Period Over Period analysis by creating predefined "analysis periods" and "breakdowns." This method uses one parameter, one filter, and several dimensions that help filter dates according to the selected parameter. Here&rsquo;s how it works:</span></span><ol><li><span><span style="font-weight:700">This Week vs Same Week Last Year (WoWLY)</span><span>: Compares the current week with the same week last year, with a filter to adjust for incomplete weeks.</span></span></li><li><span><span style="font-weight:700">This Month vs Same Month Last Year (MoMLY)</span><span>: Compares the current month with the same month last year, adjusting for incomplete months.</span></span></li><li><span><span style="font-weight:700">This Year vs Last Year (YoYLY)</span><span>: Compares the current year to the previous year, with adjustments for incomplete years.</span></span></li><li><span><span style="font-weight:700">Cyber 5 This Year vs Cyber 5 Last Year</span><span>: Compares Cyber 5 periods from two consecutive years. For example, to compare 2023 vs. 2022, we would look at the respective date ranges (Nov 23-28, 2023 vs Nov 24-29, 2022). The filter subtracts 364 days to create accurate comparisons.</span></span></li></ol> <span><span>Furthermore, by using a date dimension table we are able to scale the period-over-period capability to several explores.</span></span></div>  <h2 class="wsite-content-title"><span style="font-weight:normal"><span style="font-weight:700"><font size="4" color="#818181">Implementing a view to enable period over period dimensions in Looker</font></span></span></h2>  <div class="paragraph" style="text-align:justify;"><span>To implement this:</span><ol><li>Create view based on&nbsp;a date dimension table.&nbsp;</li><li>Create an extended View: Start by creating a view which extends the date dimension view created above to add the custom logic that enables PoP (this custom logic is mentioned below)</li><li>Join the View: Join the extended date dimension period over period view on the date field with the date field of the other view where needed.</li></ol></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:left"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/daily-sales-latest-join-to-update_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div class="wsite-image wsite-image-border-medium " style="padding-top:5px;padding-bottom:10px;margin-left:0px;margin-right:10px;text-align:left"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/view-and-view-extends_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><span><span style="font-weight:700"><font size="4">Our Customized PoP Analysis Solution</font></span></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/our-pop-analysis-solution_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><strong><span><span>1. PoP Pivot Dimension</span></span></strong><br /><span><span>The </span><span style="font-weight:700">PoP Pivot</span><span> dimension compares two periods directly, visualizing them in charts like lines or bars. This allows us to see each period (e.g., "This Month" vs "Same Month Last Year") in separate visual elements.&nbsp;</span></span><span><span>For example, the values might look like:</span></span><ul><li><span><span style="font-weight:700">04-2024</span><span> (current period) vs </span><span style="font-weight:700">04-2023</span><span> (last year)</span></span>&nbsp;<span><span>&#8203;</span></span><br /></li></ul><span><span>&#8203;</span></span><em style="color:rgb(29, 28, 29)"><font size="2"><strong>Note : </strong>The code snippets below are built using Snowflake syntax. Please modify the syntax to match code base.</font></em></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/pop-pivot_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><span><span>The values &ldquo;MTDoMTDLY&rdquo; etc. indicate the specific comparison being made. For example, &ldquo;MTDoMTDLY&rdquo; is used for Month to Date vs. Month to Date LY.</span></span><br /><span><span><br /><strong>2. PoP Row Dimension</strong><br /></span></span><span><span>The </span><span style="font-weight:700">PoP Row</span><span> dimension breaks down periods into granularity like days, weeks, or months. Since the dates will differ between comparison periods, we use metrics like "Week of Year" or "Day of Year" rather than specific dates.</span></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/pop-row_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><strong><span><span>3. Sort By<br />&#8203;</span></span></strong><span><span>Sorting ensures that the PoP Pivot and PoP Rows are displayed in logical order. For instance, in a Cyber 5 comparison, we want to see the rows ordered as Thursday, Friday, Saturday, Sunday, and Monday.</span></span><br /><span><span>We accomplish this by sorting based on a combination of "week of year" and "day of week."</span></span><ul><li><span><span style="font-weight:700">Sort_by1</span><span> sorts the PoP Row dimension.</span></span></li><li><span><span style="font-weight:700">Sort_by2</span><span> sorts the PoP Pivot dimension if necessary.</span></span></li></ul></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/sort-by-1-2_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><strong><span><span>4. Filter Date<br />&#8203;</span></span></strong><span><span>The </span><span style="font-weight:700">Filter Date</span><span> helps to accurately filter date ranges for the periods you&rsquo;re comparing. For example, if you&rsquo;re comparing "This Month vs Same Month Last Year," Filter Date selects the appropriate date ranges for analysis by setting the start and end dates for both periods.</span></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/filter-date_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><strong><span><span>5. To-Date</span></span></strong><br /><span><span>The </span><span style="font-weight:700">To-Date</span><span> filter ensures you're comparing &ldquo;apples to apples&rdquo; by matching incomplete periods. For instance, if today is Wednesday and you&rsquo;re comparing this week to the same week last year, To-Date ensures that only the first three days of data are compared, making the analysis fair.</span></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0px;margin-right:10px;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/without-to-date_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%">Without the To-Date Filter</div> </div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0px;margin-right:0px;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/editor/with-to-date.jpg?1730202700" alt="Picture" style="width:837;max-width:100%" /> </a> <div style="display:block;font-size:90%">With the To-Date filter</div> </div></div>  <div class="paragraph">As seen above with the To-Date filter you can limit the previous period to the days in the current period and compare apples to apples.</div>  <div class="paragraph"><strong><span><span><font size="4">Conclusion</font></span></span></strong><br /><span><span>Implementing Period Over Period analysis in Looker can be straightforward with built-in methods, but it becomes even more powerful when customized to meet specific business needs. Our approach allows you to create predefined periods, compare them more effectively, and visualize the data in meaningful ways.</span></span><br /><span>If you&rsquo;d like assistance implementing this in your Looker environment, don&rsquo;t hesitate to <a href="https://www.nupanch.com/contact.html" target="_blank">reach out to us at Nupanch</a>.</span></div>  <div class="paragraph" style="text-align:justify;"><span><span><strong><font size="4">Appendix: Key Code Snippets</font></strong></span></span><br /><span><span>Here are some handy snippets for reference when setting up your analysis:</span><br /><span>Current_date : </span></span>&#8203;</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/current-date_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><span><span>Current_day : </span></span>&#8203;</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/current-day_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><span><span>Current_month :</span></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/current-month_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><span><span>Current_year :</span></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/current-year_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><span><span>Current_week_start : Code snippet below is for Sunday as week Start. Can remove DateAdd if Monday is required as start of the week</span></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/current-week-start_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div style="height: 20px; overflow: hidden; width: 100%;"></div> <hr class="styled-hr" style="width:100%;"></hr> <div style="height: 20px; overflow: hidden; width: 100%;"></div></div>  <div><div class="wsite-multicol"><div class="wsite-multicol-table-wrap" style="margin:0 -15px;"> 	<table class="wsite-multicol-table"> 		<tbody class="wsite-multicol-tbody"> 			<tr class="wsite-multicol-tr"> 				<td class="wsite-multicol-col" style="width:51.095732410611%; padding:0 15px;"> 					 						  <div><div class="wsite-multicol"><div class="wsite-multicol-table-wrap" style="margin:0 -15px;"> 	<table class="wsite-multicol-table"> 		<tbody class="wsite-multicol-tbody"> 			<tr class="wsite-multicol-tr"> 				<td class="wsite-multicol-col" style="width:34.162895927602%; padding:0 15px;"> 					 						  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/editor/squarepic-20210217-18451289.jpg?1730205911" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>   					 				</td>				<td class="wsite-multicol-col" style="width:65.837104072398%; padding:0 15px;"> 					 						  <div class="wsite-spacer" style="height:50px;"></div>   					 				</td>			</tr> 		</tbody> 	</table> </div></div></div>  <h2 class="blog-author-title" style="text-align:justify;"><strong><font color="#3f3f3f" size="4">Ashish Masand</font></strong></h2> <p style="text-align:justify;"><strong><font size="2">&#8203;Lead Data Analyst</font></strong></p>   					 				</td>				<td class="wsite-multicol-col" style="width:48.904267589389%; padding:0 15px;"> 					 						  <div><div class="wsite-multicol"><div class="wsite-multicol-table-wrap" style="margin:0 -15px;"> 	<table class="wsite-multicol-table"> 		<tbody class="wsite-multicol-tbody"> 			<tr class="wsite-multicol-tr"> 				<td class="wsite-multicol-col" style="width:50%; padding:0 15px;"> 					 						  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:left"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/editor/profile-pic.jpg?1730205978" alt="Picture" style="width:128;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>   					 				</td>				<td class="wsite-multicol-col" style="width:50%; padding:0 15px;"> 					 						  <div class="wsite-spacer" style="height:50px;"></div>   					 				</td>			</tr> 		</tbody> 	</table> </div></div></div>  <h2 class="blog-author-title"><font size="4">Shridhar Patil</font></h2> <p><strong><font size="2">Data Analyst</font></strong></p>   					 				</td>			</tr> 		</tbody> 	</table> </div></div></div>  <div style="text-align:center;"><div style="height: 10px; overflow: hidden;"></div> <a class="wsite-button wsite-button-small wsite-button-highlight" href="https://www.nupanch.com/contact.html" target="_blank"> <span class="wsite-button-inner">Get in touch</span> </a> <div style="height: 10px; overflow: hidden;"></div></div>]]></content:encoded></item><item><title><![CDATA[How to forecast sales of new products]]></title><link><![CDATA[http://www.nupanch.com/blog/how-to-forecast-sales-of-new-products]]></link><comments><![CDATA[http://www.nupanch.com/blog/how-to-forecast-sales-of-new-products#comments]]></comments><pubDate>Fri, 22 Jun 2018 07:07:58 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.nupanch.com/blog/how-to-forecast-sales-of-new-products</guid><description><![CDATA[       One of the biggest problems that eCommerce companies face is inventory management. Having too little or too much inventory for a product lowers profitability. Lack of inventory can also mean a lost customer. There are many solutions for inventory management today. Most of these focus on forecasting sales for existing products or newer versions of existing products. There are fewer and less proven methods for forecasting sales of completely new products. And understandably so - without any [...] ]]></description><content:encoded><![CDATA[<div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/published/sales-forecast-icon.png?1530004646" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><span>One of the biggest problems that eCommerce companies face is inventory management. Having too little or too much inventory for a product lowers profitability. Lack of inventory can also mean a lost customer. </span><br /><br /><span>There are many solutions for inventory management today. </span><span><span><span>Most of these focus on forecasting sales for existing products or newer versions of existing products</span></span></span><span>. </span><span><span><span>There are fewer and less proven methods for forecasting sales of completely new products</span></span></span><span>. </span><span><span><span>And </span></span></span><span><span><span>understandably</span></span></span><span><span><span> so - without any historical sales data for comparable products, it is more intuition than science</span></span></span><span>.</span></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph"><span>That said, there are ways to get some idea of how a new product will sell. </span><span><span><span>Instead of </span></span></span><span><span><span>directly</span></span></span><span><span><span> looking for comparable products, information about product life cycles can </span></span></span><span><span><span>be used</span></span></span><span>. </span><br /><br /><span><span><span>Newly</span></span></span><span><span><span> launched products are likely to have a life cycle </span></span></span><span><span><span>similar to</span></span></span><span><span><span> at least some products launched in the past couple of years</span></span></span><span>. </span><span><span><span>With this in mind, we can input product life cycle information to a learning algorithm to create "clusters" of products with similar sales patterns</span></span></span><span>. Once we have the clusters defined, we identify commonalities within each cluster. Then, when a new product </span><span><span><span>is launched</span></span></span><span>, we only need to identify the cluster in which it falls to get a sales forecast. </span><br /><br /><span style="color:rgb(129, 129, 129)">Here are the steps you will want to follow -</span><ol><li>Identify the newly launched products in the past couple of years.</li><li>For each of these products, obtain its number of units sold in months 1 through 12.</li><li>Transform the&nbsp;data points to those that represent the life cycle -<ul><li>3 data points for the number of units sold in months 1-3.</li><li>3 data points for average units sold per month from Q2 (second quarter), Q3 and Q4.</li><li>3 data points for the ratio of units sold in Q2/Q1, Q3/Q2 and Q4/Q3.</li></ul></li><li>For each cluster output from the clustering algorithm, identify characteristics that define the cluster. Some examples of characteristics are -<ul><li>Brand/manufacturer of the product</li><li>Top-level and lower-level categories of products</li><li>Price range of product</li></ul></li><li>When a new product is being launched, identify the cluster in which it will fall using the cluster characteristics defined in step 4.</li><li>That cluster's sales pattern will likely apply to the newly launched product.</li></ol> &#8203;<br />Note: There is always a margin of error in forecasts, so this should always be supplemented with other qualitative information about the new product.<br /><br />Need help setting up the above steps? <a href="http://www.nupanch.com/contact.html">Reach out here.</a></div>]]></content:encoded></item><item><title><![CDATA[Smart Strategies to get answers from data]]></title><link><![CDATA[http://www.nupanch.com/blog/smart-strategies-to-get-answers-from-data]]></link><comments><![CDATA[http://www.nupanch.com/blog/smart-strategies-to-get-answers-from-data#comments]]></comments><pubDate>Mon, 04 Jun 2018 11:13:23 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.nupanch.com/blog/smart-strategies-to-get-answers-from-data</guid><description><![CDATA[You get your hands on a new data set. The goal - to get a deeper understanding of a specific phenomenon, say churn. You do the due diligence - eyeball the data to see what data points it contains and prepare some basic summaries (averages, medians etc.). Then you start asking questions of the data to get a better understanding of churn. However, after building out a few reports, nothing stands out. The behavior of users who end up churning seems very similar to users who renew. Their interaction [...] ]]></description><content:encoded><![CDATA[<div class="paragraph"><span>You get your hands on a new data set. The goal - to get a deeper understanding of a specific phenomenon, say churn. You do the due diligence - eyeball the data to see what data points it contains and prepare some basic summaries (averages, medians etc.). Then you start asking questions of the data to get a better understanding of churn. </span><br /><br /><span><span><span>However</span></span></span><span>, after building out a few reports, nothing stands out. The behavior of users who end up churning seems very </span><span><span><span>similar to</span></span></span><span> users who renew. Their interactions with your product/service are not very different. Customer support metrics are </span><span><span><span>equally</span></span></span><span> positive. &#8203;<br /><br />This leaves you confused and a bit apprehensive. If there are no visible differences or indicators, how do you optimize renewal?</span></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph"><strong style="color:rgb(129, 129, 129)">&nbsp; &nbsp; 1) Use The Right Visualization</strong><br /><br /><span style="color:rgb(129, 129, 129)">The importance of accurate data presentation cannot be stressed enough. The wrong visualization can obscure insights. Here's a basic guide to using the right chart types -</span><ul style="color:rgb(129, 129, 129)"><li>Identifying correlations between variables - scatter plots</li><li>Showing a trend over time - line charts</li><li>Showing distribution of a single variable - histograms</li><li>Comparing variables - column charts and bar graphs</li></ul><br />Additionally, a table of data can also be the right presentation format. When the result is less than 4X4 cells, it is easy for the eye to interpret it.<br /><br /><strong>&nbsp; &nbsp; 2) 5 Whys Approach</strong><br /><br /><span style="color:rgb(129, 129, 129)">The trick to getting the data to talk is to ask a ton of questions. You won&rsquo;t be able to generate a ton of questions right from the beginning, though, and that&rsquo;s normal. The idea is to let the answers to your questions beget more questions.</span><br /><br />Find the smallest indicator you can observe from your initial set of reports, and ask why that indicator might exist. The moment you ask why, your brain generates guesses and opinions. Do this 5 times, and you&rsquo;ll be drowning in ideas for reports.<br /><br />Let&rsquo;s continue with the example of analyzing customer churn -<br /><br /><ul style="color:rgb(129, 129, 129)"><li>Let&rsquo;s say you observe that the group of customers that has interacted with your product/service in the past has a higher renewal rate. That&rsquo;s&nbsp;great, but not enough to be actionable. You obviously don&rsquo;t want to discourage new customers from subscribing to this product.</li><li>What about their past experience might have caused them to renew?</li><li>You build some more investigative reports to dig into their previous activity. It turns out&nbsp;a significant percentage had earlier signed up for a newsletter. Hmm.</li><li>You now have completely new direction for the analysis. What was the newsletter about? How is it related to the product you&rsquo;re analyzing churn for? A litany of questions crosses your mind and you can&rsquo;t wait to get these answers!</li></ul><br />The above example is a bit too optimistic, but you can see how digging deeper into a seemingly small observation can lead to actionable insights.<br /><br /><strong>&nbsp; &nbsp; 3) Invite Opinions</strong><br /><br />We did this exercise with one of our clients recently. We built out one iteration of reports, presented its findings to the broader team, and invited their questions and thoughts. It was incredible - being experts in their industry, they were able to provide context to raw numbers. We were easily able to distinguish findings that mattered from the ones that were the result of a one-off experiment. This exercise gave us clear next steps for the second round of reports.<br /><br />Do you have other ideas and tips for getting answers from data? We&rsquo;d love to hear them in the comments below.</div>]]></content:encoded></item><item><title><![CDATA[The easy way to read sql]]></title><link><![CDATA[http://www.nupanch.com/blog/the-easy-way-to-read-sql]]></link><comments><![CDATA[http://www.nupanch.com/blog/the-easy-way-to-read-sql#comments]]></comments><pubDate>Tue, 29 May 2018 07:12:07 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.nupanch.com/blog/the-easy-way-to-read-sql</guid><description><![CDATA[Remember the first time you saw a large SQL query written by somebody else? I do. Meaningless aliases, no comments, all sub-queries and no common-table-expressions. Almost zero readability. What&rsquo;s worse is that I had to debug this query because it was resulting in a discrepancy. Where on earth do I start?      First - format the query using any one of the million tools available online. I use dpriver.Second - in the words of my database class professor, &ldquo;Read the query like the compu [...] ]]></description><content:encoded><![CDATA[<div class="paragraph"><span style="color:rgb(129, 129, 129)">Remember the first time you saw a large SQL query written by somebody else? I do. Meaningless aliases, no comments, all sub-queries and no common-table-expressions. Almost zero readability. What&rsquo;s worse is that I had to debug this query because it was resulting in a discrepancy. Where on earth do I start?</span></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph"><span>First - format the query using any one of the million tools available online. I use <a href="http://www.dpriver.com/pp/sqlformat.htm" target="_blank">dpriver</a>.</span><br /><br /><span><span>Second - in the words of my database class professor, <strong>&ldquo;Read the query like the computer reads it.&rdquo;</strong></span></span><br /><br /><span><span>When executing a query, the database management system follows a specific order of execution -</span></span><ol><li><span><span>FROM (including any joins)</span></span></li><li><span><span>WHERE</span></span></li><li><span><span>GROUP BY</span></span></li><li><span><span>HAVING</span></span></li><li><span><span>SELECT</span></span></li><li><span><span>ORDER BY</span></span></li></ol><br /><span><span>In other words -</span></span><ul><li><span><span>The system first executes the FROM clause i.e. it creates the data set on which the WHERE and SELECT clauses are to be run. This step includes any joins specified in the FROM clause. </span></span></li><li><span><span>Then, it eliminates rows from this data set by using the filters specified in the WHERE clause. </span></span></li><li><span><span>It then groups the data set by the columns specified in the GROUP BY clause, and finally runs the SELECT clause. This is why you can never use the aliases specified in the SELECT clause to filter in the WHERE clause - because the aliases haven&rsquo;t been declared yet.</span></span></li></ul><br /><span><span>Trying to understand the SELECT clause before understanding which tables are involved in the query is, to the say the least, difficult. Ignore the SELECT and jump straight to the FROM clause. Once you understand this, half the job is done.</span></span><br /><br /><em><span><span style="font-weight:700">Note:</span><span> When dealing with sub-queries, start with the innermost query and move gradually outwards.</span></span></em><br /><br /><span><span>Once you have a good understanding of the query, and have made the changes you need, be a good samaritan and rewrite parts of the query that you think can be made more readable. Specifically, I&rsquo;m a huge advocate of using the WITH clause in place of sub-queries. They enforce a sense of &ldquo;sequence&rdquo; to the query and make it easier to think through the logic of the query.</span></span><br /><br /><span><span>Let&rsquo;s say we wanted to identify the customers who have a lifetime revenue of more than $100, and then use this group as an input to our SQL query. Normally, we&rsquo;d write it as a sub-query and join it in with the rest of the query. While this does the job, the query is much more readable if a WITH clause is used for this purpose. Before the start of the query, define the WITH table:</span></span><br /><br /><em><span><span>WITH cust_group AS</span></span><br /><span><span>(SELECT customer_id, sum(order_total)</span></span><br /><span><span>FROM orders</span></span><br /><span><span>GROUP BY customer_id</span></span><br /><span><span>HAVING sum(order_total)&gt;100)</span></span></em><br /><br /><span><span>This temporary table can be joined in to the query just like any other table. Note that this is computationally as efficient as the sub-query method, just a lot more readable.</span></span><br /><br /><span><span>Hopefully, these tips help in reducing the time and frustration when reading a query written by someone else, or even one that you wrote yourself a long time ago. I&rsquo;d love to hear more tips to easily read SQL or to make SQL more readable. Please feel free to leave your thoughts in the comments below.</span></span></div>]]></content:encoded></item><item><title><![CDATA[A holistic picture of customer lifetime value]]></title><link><![CDATA[http://www.nupanch.com/blog/a-holistic-picture-of-customer-lifetime-value]]></link><comments><![CDATA[http://www.nupanch.com/blog/a-holistic-picture-of-customer-lifetime-value#comments]]></comments><pubDate>Tue, 17 Apr 2018 10:18:48 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.nupanch.com/blog/a-holistic-picture-of-customer-lifetime-value</guid><description><![CDATA[       Many eCommerce companies calculate Customer Lifetime Value (CLV) as the sum of all historical purchases for each customer. However, CLV, by definition, is a forward-looking statement. By simply considering historical purchases, the underlying assumption is that the customer will not make any further purchases. There has been significant statistical research into creating reliable probabilistic models to calculate Residual Customer Value (RLV) i.e. the dollars your customers are yet to spe [...] ]]></description><content:encoded><![CDATA[<div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/published/clv.png?1523961632" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><span style="color:rgb(129, 129, 129)">Many eCommerce companies calculate Customer Lifetime Value (CLV) as the sum of all historical purchases for each customer. However, CLV, by definition, is a forward-looking statement. By simply considering historical purchases, the underlying assumption is that the customer will not make any further purchases. There has been significant statistical research into creating reliable probabilistic models to calculate Residual Customer Value (RLV) i.e. the dollars your customers are yet to spend.</span></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph">Here are some ways in which calculating residual lifetime value can be useful for your business -<br /><br /><ul><li>Define your customers not only by what they have spent so far, but by how much they are likely to spend going forward</li><li>Identify &amp; understand the traits associated with your best and worst customers</li><li>Improve acquisition decision-making</li><li>Sales / demand forecasting</li><li>Customer service queuing</li><li>Proxy for a company&rsquo;s value</li></ul><br />The most popular of these statistical models is the Pareto/NBD model. Here is the <a href="http://www.jstor.org/stable/2631608?seq=1#page_scan_tab_contents" target="_blank">paper</a> that sets the foundation for it. It&rsquo;s full of math, so here&rsquo;s the short version -<br />&#8203;<br />The model takes as input a historical purchase log, and calculates basic RFM (recency, frequency, monetary) stats. It then spits out the following data points for each customer -<br /><br /><ul><li>PAlive - the probability (between 0-1) that the customer is &ldquo;alive&rdquo; i.e. still a customer of your business.</li><li>Expected Transactions - the predicted number of transactions the customer is likely to make in the next X months. X is defined by you and depends on how long you&rsquo;d like to predict for.&nbsp;As a rule of thumb this should not be greater than the duration for which the model has been trained.</li><li>Average Order Value - the predicted average transaction value of the customer going forward.</li></ul><br /><strong>What you will need to predict CLV</strong><br /><br /><ol><li>Historical Transaction Log - A list of orders with the customer_id, date&nbsp;and amount of the order. This list should include&nbsp;orders made by&nbsp;customers acquired between 2&nbsp;years ago and 6 months ago. For example, if today was Jan 1, 2018, the customers to be included would be the ones acquired between Jan 1, 2016 and June 30, 2017. It is okay to include customers older than 2 years (in fact, the more data the better), but not newer than 6 months ago.</li><li>R Script - The code to calculate the predictions for each customer. The <a href="https://cran.r-project.org/web/packages/BTYD/BTYD.pdf" target="_blank">"BTYD" R package</a> is perfect for this purpose. Here is a <a href="https://cran.r-project.org/web/packages/BTYD/vignettes/BTYD-walkthrough.pdf" target="_blank">walkthrough of the code</a>.</li><li>Export to BI Tool - Ideally, you will want a way to automate the above steps 1-2 times a&nbsp;month. If you are using a BI tool, use API access to set up an automated export/import process.</li></ol><br />Need help setting this up? Feel free to <a href="https://www.nupanch.com/contact.html" target="_blank">reach out here</a>.<br /><br /><span style="color:rgb(129, 129, 129)"><strong>Note:</strong> This method is suitable for non-subscription businesses only. For subscription businesses, there are a host of other methods that can be used. Another post to follow shortly!</span></div>]]></content:encoded></item><item><title><![CDATA[Do you need a business intelligence tool?]]></title><link><![CDATA[http://www.nupanch.com/blog/do-you-need-a-business-intelligence-tool]]></link><comments><![CDATA[http://www.nupanch.com/blog/do-you-need-a-business-intelligence-tool#comments]]></comments><pubDate>Mon, 05 Mar 2018 17:49:19 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.nupanch.com/blog/do-you-need-a-business-intelligence-tool</guid><description><![CDATA[       The short answer is Yes. Heck Yes. At some point during an e-commerce company&rsquo;s growth, teams begin to organically form, and team members begin asking &ldquo;why&rdquo; and &ldquo;how many&rdquo; questions. This often happens when new customers are being acquired, and it&rsquo;s not easily clear where they came from. You&rsquo;re no longer measuring marketing ROI by the revenue that came in during the campaign only. Now you&rsquo;re looking at customer lifetime revenue as the &ldquo [...] ]]></description><content:encoded><![CDATA[<div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/business-intelligence_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><span style="color:rgb(129, 129, 129)">The short answer is Yes. Heck Yes. At some point during an e-commerce company&rsquo;s growth, teams begin to organically form, and team members begin asking &ldquo;why&rdquo; and &ldquo;how many&rdquo; questions. This often happens when new customers are being acquired, and it&rsquo;s not easily clear where they came from. You&rsquo;re no longer measuring marketing ROI by the revenue that came in during the campaign only. Now you&rsquo;re looking at customer lifetime revenue as the &ldquo;return&rdquo; part of the equation.</span></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph"><span><span>Up until this point, Google Analytics and Excel are the primary tools used to get visibility into the business. Excel, for obvious reasons like the lack of dynamic reporting, scalability and easy sharing, soon becomes tedious to maintain. And Google Analytics becomes a black box i.e. it is no longer capable of answering the &ldquo;why&rdquo; questions.</span></span><br /><br /><span><span>&#8203;Here are some persuasive reasons to invest in a BI tool. Yes, it may cost a bit more, but you&rsquo;re no longer the same company you were yesterday.</span></span><br /><br /><br /><strong><span><span><font size="4">Data Driven Culture</font></span></span></strong><br /><br /><span><span>When the organization has morphed from one big team where everyone is doing everything to 3-4 teams with loosely defined responsibilities, each team member automatically becomes an owner of at least one metric. And each team member should be able to keep track of that metric easily. This includes the Customer Success Teams - they should be able to keep track of metrics like Churn and Support Satisfaction. They should be able to correlate their functions to the top line of their teams and their companies.</span></span><br /><br /><br /><strong><span><span><font size="4">Single Source of Truth</font></span></span></strong><br /><br /><span><span><strong>At the data source level</strong> - when you have multiple data sources - transactional data, marketing, support, sales, engineering - connecting them together unlocks a whole new world of analytics for your business. You can now identify whether/how a customer&rsquo;s outreach to support affects their lifetime revenue or average order value. You can identify whether your engineering team&rsquo;s process is aligned with your support team&rsquo;s process so that bugs are being fixed swiftly.</span></span><br /><br /><span><span><strong>At the metric level</strong> - Different teams at the organization now begin to track the same metric. For example, the executive team and the marketing team both measure &ldquo;New Customers&rdquo;. However, without having a BI tool where this metric&rsquo;s definition is common for all teams could result in the teams defining it in different ways. For example, the marketing team would consider a new customer as anyone who has made a first order. However, the executive team might have a stricter view of this metric. They may consider only a repeat purchaser to be a new customer because that&rsquo;s what they consider important. While both perspectives may be right, it is important that both teams use the same definition so that they are working towards the same goal. In this above case, the marketing team is not thinking of repeat purchases when acquiring customers even though that is the expectation of the executive team.</span></span><br /><br /><br /><strong><span><span><font size="4">Flexibility</font></span></span></strong><br /><br /><span><span>All this is to say that a BI tool, where everyone has access to their team&rsquo;s analytics, results in flexibility in operations. A BI tool means that new questions can be asked of he business every single day. These questions engender more questions, which finally uncover the answer to the &ldquo;why&rdquo;.</span></span><br /><br /><span><span>Have questions about the business intelligence and analytics at your company? Feel free to comment below, or reach out here.</span></span></div>]]></content:encoded></item><item><title><![CDATA[Flattening the magento eav structure in SQL]]></title><link><![CDATA[http://www.nupanch.com/blog/flattening-the-magento-eav-structure-in-sql]]></link><comments><![CDATA[http://www.nupanch.com/blog/flattening-the-magento-eav-structure-in-sql#comments]]></comments><pubDate>Fri, 02 Feb 2018 04:48:56 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.nupanch.com/blog/flattening-the-magento-eav-structure-in-sql</guid><description><![CDATA[       The Magento EAV structure is one that is designed for scalability, but loses efficiency when it comes to data analysis. Due to the use of multiple tables for storing the &ldquo;entity&rdquo;, &ldquo;attribute&rdquo; and then the &ldquo;value&rdquo;, a SQL query to perform complex product analyses is required to perform joins across several tables. This article outlines an approach to &ldquo;flatten&rdquo; this structure so that all products and their associated attributes are stored in th [...] ]]></description><content:encoded><![CDATA[<div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/editor/flattening-concept.png?1517548346" alt="Picture" style="width:447;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><span style="color:rgb(129, 129, 129)">The Magento EAV structure is one that is designed for scalability, but loses efficiency when it comes to data analysis. Due to the use of multiple tables for storing the &ldquo;entity&rdquo;, &ldquo;attribute&rdquo; and then the &ldquo;value&rdquo;, a SQL query to perform complex product analyses is required to perform joins across several tables. This article outlines an approach to &ldquo;flatten&rdquo; this structure so that all products and their associated attributes are stored in the same table, allowing for easy analysis.</span></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph"><span><span>The SQL query to be used to flatten the product EAV model is given at the end of the article.</span></span><br /><br /><span><span>On running the query, the resulting table will have the below format. Each product will have multiple rows, each row associated with a different attribute. For example, in the below example, the product with SKU &nbsp;8132 has 3 rows - color, size and status. The product with SKU 9145, on the other hand, has only two rows because it has two attributes associated with it - color and size.</span></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/sample-result-table_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><br /><span>&#8203;The below SQL query is made up of 4 smaller queries. These 4 queries are identical, except that each one references a different data type table in the EAV structure - int, varchar, decimal and datetime. Individual parts can be removed from the query as required.<br /><br />Still have questions? Leave a comment or <a href="http://www.nupanch.com/contact.html">reach out</a>!</span><br /><br /><span><span style="color:rgb(128, 0, 0)"></span></span><font color="maroon">(</font><font color="blue">SELECT</font><span>&nbsp;</span><font color="maroon">p</font><font color="silver">.</font><font color="maroon">entity_id</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">p</font><font color="silver">.</font><font color="maroon">sku</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">ea</font><font color="silver">.</font><font color="maroon">attribute_id</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">ea</font><font color="silver">.</font><font color="maroon">frontend_label</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><font color="silver">::</font><span>&nbsp;</span><font color="maroon">text</font><span>&nbsp;</span><font color="blue">AS</font><span>&nbsp;</span><font color="maroon">int_value</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">CASE</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">WHEN</font><span>&nbsp;</span><font color="maroon">eaov</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><font color="blue">IS</font><span>&nbsp;</span><font color="blue">NULL</font><span>&nbsp;</span><font color="blue">THEN</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><font color="silver">::</font><span>&nbsp;</span><font color="maroon">text</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ELSE</font><span>&nbsp;</span><font color="maroon">eaov</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">END</font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">AS</font><span>&nbsp;</span><font color="maroon">value</font><span>&nbsp;</span><br /><span>&nbsp;</span><font color="blue">FROM</font><span>&nbsp;&nbsp;&nbsp;</span><font color="maroon">catalog_product_entity</font><span>&nbsp;</span><font color="maroon">p</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">left</font><span>&nbsp;</span><font color="maroon">join</font><span>&nbsp;</span><font color="maroon">catalog_product_entity_int</font><span>&nbsp;</span><font color="maroon">pi</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ON</font><span>&nbsp;</span><font color="maroon">p</font><font color="silver">.</font><font color="maroon">entity_id</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">entity_id</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">left</font><span>&nbsp;</span><font color="maroon">join</font><span>&nbsp;</span><font color="maroon">eav_attribute</font><span>&nbsp;</span><font color="maroon">ea</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ON</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">attribute_id</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">ea</font><font color="silver">.</font><font color="maroon">attribute_id</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">left</font><span>&nbsp;</span><font color="maroon">join</font><span>&nbsp;</span><font color="maroon">eav_attribute_option</font><span>&nbsp;</span><font color="maroon">eao</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ON</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">eao</font><font color="silver">.</font><font color="maroon">option_id</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">AND</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">attribute_id</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">eao</font><font color="silver">.</font><font color="maroon">attribute_id</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">left</font><span>&nbsp;</span><font color="maroon">join</font><span>&nbsp;</span><font color="maroon">eav_attribute_option_value</font><span>&nbsp;</span><font color="maroon">eaov</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ON</font><span>&nbsp;</span><font color="maroon">eao</font><font color="silver">.</font><font color="maroon">option_id</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">eaov</font><font color="silver">.</font><font color="maroon">option_id</font><font color="maroon">)</font><span>&nbsp;<br /></span><br /><font color="blue">UNION</font><span>&nbsp;<br /></span><br /><font color="maroon">(</font><font color="blue">SELECT</font><span>&nbsp;</span><font color="maroon">p</font><font color="silver">.</font><font color="maroon">entity_id</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">p</font><font color="silver">.</font><font color="maroon">sku</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">ea</font><font color="silver">.</font><font color="maroon">attribute_id</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">ea</font><font color="silver">.</font><font color="maroon">frontend_label</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><font color="blue">AS</font><span>&nbsp;</span><font color="maroon">int_value</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">CASE</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">WHEN</font><span>&nbsp;</span><font color="maroon">eaov</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><font color="blue">IS</font><span>&nbsp;</span><font color="blue">NULL</font><span>&nbsp;</span><font color="blue">THEN</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><font color="silver">::</font><span>&nbsp;</span><font color="maroon">text</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ELSE</font><span>&nbsp;</span><font color="maroon">eaov</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><font color="silver">::</font><span>&nbsp;</span><font color="maroon">text</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">END</font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">AS</font><span>&nbsp;</span><font color="maroon">value</font><span>&nbsp;</span><br /><span>&nbsp;</span><font color="blue">FROM</font><span>&nbsp;&nbsp;&nbsp;</span><font color="maroon">catalog_product_entity</font><span>&nbsp;</span><font color="maroon">p</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">left</font><span>&nbsp;</span><font color="maroon">join</font><span>&nbsp;</span><font color="maroon">catalog_product_entity_varchar</font><span>&nbsp;</span><font color="maroon">pi</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ON</font><span>&nbsp;</span><font color="maroon">p</font><font color="silver">.</font><font color="maroon">entity_id</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">entity_id</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">left</font><span>&nbsp;</span><font color="maroon">join</font><span>&nbsp;</span><font color="maroon">eav_attribute</font><span>&nbsp;</span><font color="maroon">ea</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ON</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">attribute_id</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">ea</font><font color="silver">.</font><font color="maroon">attribute_id</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">left</font><span>&nbsp;</span><font color="maroon">join</font><span>&nbsp;</span><font color="maroon">eav_attribute_option</font><span>&nbsp;</span><font color="maroon">eao</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ON</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">eao</font><font color="silver">.</font><font color="maroon">option_id</font><span>&nbsp;</span><font color="silver">::</font><span>&nbsp;</span><font color="maroon">text</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">AND</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">attribute_id</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">eao</font><font color="silver">.</font><font color="maroon">attribute_id</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">left</font><span>&nbsp;</span><font color="maroon">join</font><span>&nbsp;</span><font color="maroon">eav_attribute_option_value</font><span>&nbsp;</span><font color="maroon">eaov</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ON</font><span>&nbsp;</span><font color="maroon">eao</font><font color="silver">.</font><font color="maroon">option_id</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">eaov</font><font color="silver">.</font><font color="maroon">option_id</font><font color="maroon">)</font><span>&nbsp;<br /></span><br /><font color="blue">UNION</font><span>&nbsp;<br />&#8203;</span><br /><font color="maroon">(</font><font color="blue">SELECT</font><span>&nbsp;</span><font color="maroon">p</font><font color="silver">.</font><font color="maroon">entity_id</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">p</font><font color="silver">.</font><font color="maroon">sku</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">ea</font><font color="silver">.</font><font color="maroon">attribute_id</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">ea</font><font color="silver">.</font><font color="maroon">frontend_label</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><font color="silver">::</font><span>&nbsp;</span><font color="maroon">text</font><span>&nbsp;</span><font color="blue">AS</font><span>&nbsp;</span><font color="maroon">int_value</font><font color="silver">,</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">CASE</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">WHEN</font><span>&nbsp;</span><font color="maroon">eaov</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><font color="blue">IS</font><span>&nbsp;</span><font color="blue">NULL</font><span>&nbsp;</span><font color="blue">THEN</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><font color="silver">::</font><span>&nbsp;</span><font color="maroon">text</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ELSE</font><span>&nbsp;</span><font color="maroon">eaov</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">END</font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">AS</font><span>&nbsp;</span><font color="maroon">value</font><span>&nbsp;</span><br /><span>&nbsp;</span><font color="blue">FROM</font><span>&nbsp;&nbsp;&nbsp;</span><font color="maroon">catalog_product_entity</font><span>&nbsp;</span><font color="maroon">p</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">left</font><span>&nbsp;</span><font color="maroon">join</font><span>&nbsp;</span><font color="maroon">catalog_product_entity_decimal</font><span>&nbsp;</span><font color="maroon">pi</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ON</font><span>&nbsp;</span><font color="maroon">p</font><font color="silver">.</font><font color="maroon">entity_id</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">entity_id</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">left</font><span>&nbsp;</span><font color="maroon">join</font><span>&nbsp;</span><font color="maroon">eav_attribute</font><span>&nbsp;</span><font color="maroon">ea</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ON</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">attribute_id</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">ea</font><font color="silver">.</font><font color="maroon">attribute_id</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">left</font><span>&nbsp;</span><font color="maroon">join</font><span>&nbsp;</span><font color="maroon">eav_attribute_option</font><span>&nbsp;</span><font color="maroon">eao</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ON</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">value</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">eao</font><font color="silver">.</font><font color="maroon">option_id</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">AND</font><span>&nbsp;</span><font color="maroon">pi</font><font color="silver">.</font><font color="maroon">attribute_id</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">eao</font><font color="silver">.</font><font color="maroon">attribute_id</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="maroon">left</font><span>&nbsp;</span><font color="maroon">join</font><span>&nbsp;</span><font color="maroon">eav_attribute_option_value</font><span>&nbsp;</span><font color="maroon">eaov</font><span>&nbsp;</span><br /><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="blue">ON</font><span>&nbsp;</span><font color="maroon">eao</font><font color="silver">.</font><font color="maroon">option_id</font><span>&nbsp;</span><font color="silver">=</font><span>&nbsp;</span><font color="maroon">eaov</font><font color="silver">.</font><font color="maroon">option_id</font><font color="maroon">)</font><span>&nbsp;</span><span style="color:rgb(128, 0, 0)"></span></div>]]></content:encoded></item><item><title><![CDATA[magento bi - Getting the most out of it]]></title><link><![CDATA[http://www.nupanch.com/blog/magento-bi-making-the-most-of-it]]></link><comments><![CDATA[http://www.nupanch.com/blog/magento-bi-making-the-most-of-it#comments]]></comments><pubDate>Thu, 25 Jan 2018 10:11:01 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.nupanch.com/blog/magento-bi-making-the-most-of-it</guid><description><![CDATA[       In July 2016, Magento acquired&nbsp;RJMetrics, a business intelligence platform designed primarily for e-commerce analytics. This product has now been branded as Magento Business Intelligence, offering a full stack BI product to Magento merchants.       Having worked as an analyst with RJMetrics and then Magento for a combined 3 years in the city of brotherly love, I&rsquo;ve worked with over 200 small to medium sized e-commerce customers, advising them on best practices in using the prod [...] ]]></description><content:encoded><![CDATA[<div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/editor/take-off_1.png?1517392781" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><span style="color:rgb(129, 129, 129)">In July 2016, Magento acquired&nbsp;</span><a href="https://www.rjmetrics.com/" target="_blank">RJMetrics</a><span style="color:rgb(129, 129, 129)">, a business intelligence platform designed primarily for e-commerce analytics. This product has now been branded as Magento Business Intelligence, offering a full stack BI product to Magento merchants.</span></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <span class='imgPusher' style='float:left;height:1100px'></span><span style='display: table;width:623px;position:relative;float:left;max-width:100%;;clear:left;margin-top:20px;*margin-top:40px'><a><img src="http://www.nupanch.com/uploads/1/1/7/1/117119861/published/tables.png?1516875798" style="margin-top: 5px; margin-bottom: 10px; margin-left: 0px; margin-right: 10px; border-width:1px;padding:3px; max-width:100%" alt="Picture" class="galleryImageBorder wsite-image" /></a><span style="display: table-caption; caption-side: bottom; font-size: 90%; margin-top: -10px; margin-bottom: 10px; text-align: center;" class="wsite-caption"></span></span> <div class="paragraph" style="text-align:justify;display:block;"><span><span>Having worked as an analyst with RJMetrics and then Magento for a combined 3 years in the city of brotherly love, I&rsquo;ve worked with over 200 small to medium sized e-commerce customers, advising them on best practices in using the product, building reports, as well as maintaining an optimized data warehouse. I now work independently, consulting with merchants to make the most of their reporting and analytics efforts. It only took me 3 years to realize that there should be content about the most common questions that customers asked about (and sometimes dreaded) when using Magento Business Intelligence. Read on!</span></span><br /><br /><span><span style="font-weight:700">What&rsquo;s a replication method, and which one should we use?</span></span><br /><br /><span>For a Magento database, most tables have an auto-incrementing numeric primary key column called &ldquo;entity_id&rdquo;. Hence, using the &ldquo;Auto-Incrementing Primary Key&rdquo; <a href="https://support.rjmetrics.com/hc/en-us/articles/206462945-Configuring-replication-methods" target="_blank">replication method</a> is the recommended option for most tables. For some other tables that have a combination of two or more columns as the primary key, like &ldquo;catalog_category_product&rdquo;, the &ldquo;Primary Key Batch Monitoring&rdquo; option is best. That said, if the &ldquo;updated_at&rdquo; column on the database tables is set up correctly - i.e. it is a timestamp that is automatically updated when a row is updated - the &ldquo;Modified At&rdquo; replication method is the best option.</span><br /><br /><span><span style="font-weight:700">Is there a difference in the direction of setting up paths - one-to-many or many-to-one?</span></span><br /><br /><span><span>Yes. When setting up paths between tables, think about the two tables you are connecting. For example, let&rsquo;s say you are connecting the &ldquo;orders&rdquo; and &ldquo;line items&rdquo; tables. Ask yourself, &ldquo;Does a single order have multiple line items, and does a line item belong to multiple orders?&rdquo; In most cases, the answer to the first question is &ldquo;yes&rdquo;, and the second is &ldquo;no&rdquo;. Hence, in the case of these tables, the &ldquo;orders&rdquo; table is the &ldquo;one&rdquo; side of the relationship while the &ldquo;line items&rdquo; table is the &ldquo;many&rdquo; side.</span></span><br /><br />&#8203;<br /><span><span>&#8203;Consequently, when bringing a column from the &ldquo;orders&rdquo; table to the &ldquo;line items&rdquo; table, it can be brought over as a &ldquo;Joined Column&rdquo;. All information about an order is also valid for all its associated line items. On the other hand, a column cannot be brought from &ldquo;line items&rdquo; to &ldquo;orders&rdquo; using a &ldquo;Joined Column&rdquo; because an order could have more than one distinct associated line item. So, when bringing data from &ldquo;line items&rdquo; to &ldquo;orders&rdquo;, an aggregation function - such as sum, average, max, min etc. - needs to be performed.</span></span><br /><br /><span><span>The concept is illustrated visually below.</span></span><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span><span>&#8203;&#8203;In the above example, let&rsquo;s consider two scenarios -</span></span><ol><li><span><span>Bringing over &ldquo;order_date&rdquo; from &ldquo;orders&rdquo; to &ldquo;line_items&rdquo; - To do this, we can link the two tables on the order_id column, and create a new &ldquo;Joined Column&rdquo; in &ldquo;line_items&rdquo; called &ldquo;order_date&rdquo;. This column will contain the same value for each line item of an order. For example, the rows with &ldquo;item_id&rdquo; 1000 and 1001 will have the order_date Jan 1, 2017.</span></span></li><li><span><span>Bringing over &ldquo;quantity&rdquo; from &ldquo;line_items&rdquo; to &ldquo;orders&rdquo; - Since each order has more than one associated line item, &ldquo;quantity&rdquo; will need to be summed up from the &ldquo;line_items&rdquo; table and then brought over to &ldquo;orders&rdquo;. To do this, choose the &ldquo;Many-to-one&rdquo; type of column, and then choose the &ldquo;Sum&rdquo; operation. For example, the newly created &ldquo;quantity&rdquo; column in &ldquo;orders&rdquo; table will contain a value of 6 for the order with order_id 3.</span></span></li></ol><br /><span><span style="font-weight:700">Which table should metrics be built on?</span></span><br /><br /><span><span>The short answer is that metrics should be built on the lowest &ldquo;grain&rdquo;. &ldquo;grain&rdquo; refers to the granularity of data in the table. The &ldquo;orders&rdquo; table contains information about each order - its total amount, date, customer who purchased the order. However, it does not contain information about the line items in the order. This information lives in the &ldquo;line items&rdquo; table. Hence, &ldquo;line items&rdquo; is at a lower granularity than the &ldquo;orders&rdquo; table i.e. it contains all information that the &ldquo;orders&rdquo; table contains and then some additional information.</span></span><br /><br /><span><span>Hence, everything that can be built on the &ldquo;orders&rdquo; table can also be built on the &ldquo;line items&rdquo; table. Further, the &ldquo;line items&rdquo; table allows you to segment your data to a greater degree than the &ldquo;orders&rdquo; table due to the presence of more granular data in it.</span></span><br /><br /><span><span style="font-weight:700">How should many-to-many relationships be analyzed?</span></span><br /><br /><span>Magento BI does not have an inbuilt way to handle many-to-many relationships. To analyze data from tables sharing a many-to-many relationship, the recommended method is to use SQL - either in the SQL Report Builder or in a <a href="https://support.rjmetrics.com/hc/en-us/articles/115003453363-Creating-and-Using-Data-Warehouse-Views" target="_blank">Data Warehouse View</a>. The two tables will need to be joined, with each joined combination becoming a new row. For example, let&rsquo;s consider the case of each product being in multiple categories, and each category having multiple products. If there were a total of 4 products, each belonging to 3 different categories, the total number of combinations would be 4X3 = 12 rows. Once this join has been performed, either in the SQL Report Builder or as a Persistent View, information about these combinations can be added to these reports/views.</span><br /><br /><span>These are some of the most common questions customers of Magento BI have about how to best use the product. With MBI evolving quickly, I&rsquo;m sure there will be many more questions that haven&rsquo;t been covered above. Have other questions about best practices or looking for advice? Leave a comment or <a href="https://www.nupanch.com/contact.html" target="_blank">reach out here</a>.</span><br /><br /></div> <hr style="width:100%;clear:both;visibility:hidden;"></hr>]]></content:encoded></item></channel></rss>