<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sneha Valia on Medium]]></title>
        <description><![CDATA[Stories by Sneha Valia on Medium]]></description>
        <link>https://medium.com/@sneha.valia?source=rss-588250e6d51f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PRepepP9LmtqLQsA</url>
            <title>Stories by Sneha Valia on Medium</title>
            <link>https://medium.com/@sneha.valia?source=rss-588250e6d51f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:30:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sneha.valia/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Dynamic Time Granularity in Looker]]></title>
            <link>https://blog.searce.com/dynamic-time-granularity-in-looker-8ec4af52eb56?source=rss-588250e6d51f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ec4af52eb56</guid>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[looker]]></category>
            <category><![CDATA[lookml]]></category>
            <category><![CDATA[parameter]]></category>
            <category><![CDATA[granularity]]></category>
            <dc:creator><![CDATA[Sneha Valia]]></dc:creator>
            <pubDate>Thu, 09 Feb 2023 08:37:27 GMT</pubDate>
            <atom:updated>2023-02-10T08:15:41.727Z</atom:updated>
            <content:encoded><![CDATA[<h3>Business Case:</h3><p>How specifically do we go about accomplishing it, if there is a use case where we have to set up Time Granularity for certain charts that is different from the date filter available for the other charts in the reports?</p><p>As an illustration, the Date dimension is shown by Month in the charts below (November, December, etc.). The requirement is for dynamically changing visualisations for a date range or a time period i.e hour , quarter, year etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TtqbfTka0kBUQEkZ3l8_QQ.png" /></figure><h4>Objective :</h4><p>This blog aims to assist developers in building a different level of granularity for specific dashboard and report visualizations.</p><h4>Solution :</h4><p>The objective is to create the LookML code, build the Time Granularity parameter in Looker’s development mode and add this feature to the dashboard along with a date filter.</p><p>With the use of this parameter, you can specify a granularity for the desired charts that is distinct from the one we typically use as date filter for the dashboards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*kCZhKWFugCrwGtimpOl84w.png" /><figcaption>Time Grain Filter</figcaption></figure><h4>Steps to create a Parameter for Time Granularity :</h4><ol><li>Go to the necessary view file after creating the pertinent connection, project, model and view file (which contains the date dimension).</li><li>Create a parameter and give it a name in the LookML code.</li></ol><p><strong>A parameter name must </strong>:-</p><ul><li>Be unique within any given view.</li><li>Consist of characters a through z (no capital letters), 0 through 9, or _</li><li>Start with a letter.</li></ul><p>The name in this instance is <strong><em>(parameter: Grain)</em></strong></p><p>3. Add a type: <strong>string</strong> to the parameter. (Type string is used, because we will pass a string value in the labels of allowed_value).</p><p>Then include <strong>allowed_value</strong>.</p><ul><li>allowed_value works with the LookML parameter. Use allowed_value to define a list of values a user can choose for that parameter field.</li><li>allowed_value has two subparameters, label and value. The label subparameter specifies the options the user will see in the filter suggestions. The values passed to the% parameter% liquid variable are stored in the value subparameter.</li></ul><p>4. Define a single/list of allowed values ​​that appear as options in the filter using <strong>value</strong> attribute.</p><h4>LookML Code:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bMXYiPNbGG3rXa_t" /></figure><p>5. After defining the parameters, you need to create a dimension.</p><p>6. Create a dimension and name the dimension.</p><p><strong><em>( dimension: Time_Grain { } )</em></strong></p><p>7. Within the dimension definition, a parametric function must be assigned to this dimension. Add the parameter name <strong>Grain</strong> to the <strong>label_from_parameter</strong> created in <strong>step</strong> <strong>2</strong>.</p><p>8. Define the <strong>type</strong> <strong>as</strong> <strong>date_time</strong> as we are implementing the scenario on the date dimension group<strong>.</strong></p><p>9. Finally, in the <strong>SQL</strong> block, add a case statement for each allowed values defined in Looker using the Liquid Parameter Syntax <strong><em>{% parameter parameter_name%}</em></strong> .</p><p>10. <strong>Save</strong> the code → Validate LookML → Commit changes → Deploy to production.</p><h4>LookML Code:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fAFDx8R-Lcq1XoV4" /><figcaption>Part 2</figcaption></figure><h4>Dashboard Snippets:</h4><p>The level of granularity i.e. seconds, minutes, hours, days, weeks, months, quarters and years is shown in the following dashboard images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gL75T4claz2BRjFw" /><figcaption>Grain functionality on the dashboard</figcaption></figure><ul><li>If we select<strong> Hour</strong> in the <strong>Grain filter </strong>for a <strong>30 complete days</strong> time frame to the image below, we can see that the visuals are presenting hourly data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bs8XJLf7L5uNdu5O" /><figcaption>Sales by Hours</figcaption></figure><ul><li>Then if we switch to <strong>Week</strong> in the <strong>Grain filter </strong>for the <strong>30 complete days</strong> , the visuals shows weekly data trends in the below image.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LVjJYuFMjOQT6gkx" /><figcaption>Sales by Week</figcaption></figure><ul><li>We can also select a <strong>Month</strong> in the <strong>Grain filter</strong> and change the date range to <strong>90 days</strong> to see monthly data in the visuals.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_IlD4Ip_L6ByKGM_" /><figcaption>Sales by Months</figcaption></figure><ul><li>Likewise , we apply <strong>Quarter</strong> to the<strong> Grain filter</strong> with a <strong>date range</strong> of<strong> 365 days</strong> to effectively see quarterly results in both the visuals.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BjDm15k4uXGErQuN" /><figcaption>Sales by Quarters</figcaption></figure><ul><li>Lastly, to achieve results for a <strong>Year</strong> of the<strong> Grain filter, </strong>add the <strong>last 2 years or 730 days</strong> in the <strong>date range</strong> and there you go! You will be able to see the <strong>2 Years </strong>in the trend.</li></ul><h4>Conclusion:</h4><p>By writing the LookML code, implementing the Time granularity parameter in Looker’s development mode, and incorporating this feature into the date filter were the key objectives in this use case, where the granularity implemented for the charts required to be different from the date filter functionality applied on the charts.</p><p>Utilizing Looker’s Liquid Parameter methodology, we were able to accomplish different Time Granularity in Looker !</p><p>I’d like to thank <a href="https://medium.com/@ashwamegh.potpelwar"><strong>Ashwamegh Potpelwar</strong></a> for his contributions to the conception and execution of the aforementioned solution.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ec4af52eb56" width="1" height="1" alt=""><hr><p><a href="https://blog.searce.com/dynamic-time-granularity-in-looker-8ec4af52eb56">Dynamic Time Granularity in Looker</a> was originally published in <a href="https://blog.searce.com/">Searce</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>