<?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 Ranchana Kiriyapong on Medium]]></title>
        <description><![CDATA[Stories by Ranchana Kiriyapong on Medium]]></description>
        <link>https://medium.com/@jb.ranchana?source=rss-39d225398681------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lEHhxxvxg3omUrrqRGrfWg.jpeg</url>
            <title>Stories by Ranchana Kiriyapong on Medium</title>
            <link>https://medium.com/@jb.ranchana?source=rss-39d225398681------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 08:58:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jb.ranchana/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[I Was Building a Custom Viz Framework. Then Google Changed the Game.]]></title>
            <link>https://medium.com/@jb.ranchana/i-was-building-a-custom-viz-framework-then-google-changed-the-game-24ada512b18c?source=rss-39d225398681------2</link>
            <guid isPermaLink="false">https://medium.com/p/24ada512b18c</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[adlc]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[ai-assisted-development]]></category>
            <category><![CDATA[looker]]></category>
            <dc:creator><![CDATA[Ranchana Kiriyapong]]></dc:creator>
            <pubDate>Fri, 30 Oct 2026 05:14:16 GMT</pubDate>
            <atom:updated>2026-10-30T05:21:45.405Z</atom:updated>
            <content:encoded><![CDATA[<p><em>An unexpected turn in my development journey, and the lessons I gained about building software with AI agents.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NZZhCNjAPNyAMLL1bmZ14A.jpeg" /></figure><p>I was preparing a presentation to roll out my Looker Custom Viz development framework on Friday when a colleague mentioned that Google had just launched a new feature: <strong>Looker Data Apps</strong>.</p><p>It allows developers to build bespoke, interactive applications on top of existing Looker models and Explores, with much more flexibility than traditional dashboard layouts. What caught my attention even more was what happened next. When we spoke again on Monday, my colleague told me he had already built around ten dashboards using real data, simply through vibe coding.</p><p>I was stunned.</p><p>After taking a closer look, I began to understand why. The new feature opened up possibilities beyond the conventional visualisation types and layouts we had been working with. More importantly, it made application development significantly faster and easier.</p><p>Naturally, I started exploring the differences between my own framework and this new approach. Both have their strengths and limitations, but I have to admit that Looker Data Apps offers a much more compelling direction for certain use cases.</p><h4>A Different Approach to Building Visualisations</h4><ul><li><strong>Looker Custom Viz Framework</strong>: A reusable development framework for building customised visualisation components, with structured coding standards, QA, and CI/CD workflows.</li><li><strong>Looker Data Apps (in Preview):</strong> A way to build interactive, full-page data applications on top of Looker models and Explores, offering more flexibility in application design and AI-assisted development.</li></ul><blockquote>Looker Data Apps Reference: <a href="https://cloud.google.com/blog/products/business-intelligence/introducing-looker-data-apps">https://cloud.google.com/blog/products/business-intelligence/introducing-looker-data-apps</a></blockquote><p>Although they approach the problem differently, both aim to extend what we can build on top of Looker. The difference is in how we build, package, and maintain those experiences.</p><p>This shift also highlights something bigger than the tools themselves: the way we develop software is changing. The <strong>Agentic Development Life Cycle (ADLC)</strong> is becoming increasingly relevant as AI agents accelerate the journey from ideas to working applications.</p><h4>What I Gained Beyond the Framework</h4><p>I knew that new technology could eventually disrupt the work I was doing. I just didn’t expect it to happen quite this soon.</p><p>But looking back, I realised that the value of this journey was never just about building a Custom Viz framework.</p><p>Along the way, I learned the foundations of building software with AI agents, including how to establish development guardrails, implement automated quality checks, and create review workflows.</p><p>These are not just development conveniences. They are important foundations for building maintainable software, avoiding black-box implementations, and preventing technical debt from accumulating as AI-generated applications evolve.</p><p>I also became more aware of <strong>performance considerations</strong> in visualisation development, particularly when dealing with larger or more complex datasets. I learned that choosing the right architecture and visualisation technology involves more than just how the final result looks. It also requires considering how data is processed, rendered, and handled as complexity grows.</p><p>The framework itself may need to change. Some parts may become less relevant, while others can be reused in different contexts. But the knowledge and experience gained along the way remain valuable.</p><p>Perhaps this is what working in technology increasingly requires: <strong>learning, relearning, and sometimes unlearning.</strong></p><p>I’m still figuring out what comes next, but one thing is clear: I didn’t just learn how to build visualisations. I learned a little more about how software development is changing.</p><p><strong>Have you ever experienced a moment when new technology suddenly changed the direction of your work? How did you handle it?</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24ada512b18c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When DE assigned to develop Looker Custom Visualization : Part 4 Connecting to Looker]]></title>
            <link>https://medium.com/@jb.ranchana/when-de-assigned-to-develop-looker-custom-visualization-part-4-connecting-to-looker-9d9c2ccc6725?source=rss-39d225398681------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d9c2ccc6725</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[looker]]></category>
            <category><![CDATA[custom-visualization]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Ranchana Kiriyapong]]></dc:creator>
            <pubDate>Tue, 22 Sep 2026 16:46:11 GMT</pubDate>
            <atom:updated>2026-09-23T02:00:48.027Z</atom:updated>
            <content:encoded><![CDATA[<p>From localhost to Looker: Connecting, Bundling, and Deploying a Custom Visualization</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KMCLQqEQRWV9WhNK" /><figcaption>Photo by <a href="https://unsplash.com/@setyaki?utm_source=medium&amp;utm_medium=referral">Irham Setyaki</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>👉 In Part 3, we built the real table component with color overriding and confirmed everything worked on yarn dev. If you haven&#39;t read it yet, check it out here:</p><p><a href="https://medium.com/@jb.ranchana/when-de-assigned-to-develop-looker-custom-visualization-part-3-building-the-real-visualization-575c5cb7b7d7">When DE assigned to develop Looker Custom Visualization: Part 3 Building the Real Visualization</a></p><p>Everything so far has lived entirely on localhost. Looker has never seen a single line of our code.</p><p>In this final part, we close that gap: we’ll register the visualization with Looker’s Plugin API, bundle it into the single file Looker expects, host that file somewhere Looker can reach, and register it in Admin &gt; Visualizations.</p><p>By the end, the table you’ve been building in your browser will be running on a real dashboard, pulling real data.</p><h4>Table of Contents</h4><ol><li><a href="#7efd">looker-viz.tsx — Registering with Looker’s Plugin API</a></li><li><a href="#06e0">The create and updateAsync Lifecycle</a></li><li><a href="#0964">Bundling into One .umd.js File</a></li><li><a href="#bb78">Hosting and Registering on Looker</a></li><li><a href="#d312">The Result on Looker</a></li><li><a href="#8b6e">From a Simple Example to a Shared Viz Repository</a></li><li><a href="#5c71">How We Develop Custom Vizzes Faster</a></li><li><a href="#2076">What’s Next?</a></li></ol><h3>1. looker-viz.tsx — Registering with Looker&#39;s Plugin API</h3><p>Everything up to now (App.tsx, mock data) was for local development only. looker-viz.tsx is the file that actually talks to Looker — and it&#39;s the entry point we already pointed vite.config.ts at back in Part 2.</p><p>Looker expects one specific call: looker.plugins.visualizations.add(). This is how your bundle announces &quot;here is a visualization, here&#39;s how to draw it, here&#39;s how to redraw it.&quot;</p><pre>const MyTableViz = {<br>  // Called ONCE, when the tile first mounts.<br>  // One-time setup only — create your React root here, nothing else.<br>  create(element) {<br>    this.root = createRoot(element);<br>  },<br><br>  // Called EVERY time data, config, or tile size changes.<br>  // All rendering happens here.<br>  updateAsync(data, element, config, queryResponse, details, done) {<br>    this.root.render(&lt;MyTable data={data} config={config} /&gt;);<br><br>    // Signal completion. Skip this and the tile spins forever — with no error.<br>    done();<br>  },<br>};<br><br>// This single call is how your bundle announces itself to Looker.<br>looker.plugins.visualizations.add({<br>  ...MyTableViz,<br>  id: &quot;my_table&quot;,<br>  label: &quot;My Table&quot;,<br>  options: staticOptions,<br>});</pre><p><strong>Note:</strong></p><ul><li>The options object is the same structure we introduced in Part 3 for local development. The difference is that we’re now passing it to Looker’s Plugin API, so Looker can use it to build the configuration UI.</li></ul><p>In Part 3, we also used buildDynamicOptions() to generate additional rule options based on num_rules. Here, those dynamic options are registered through updateAsync() when the configuration changes.</p><h3>2. The create and updateAsync Lifecycle</h3><p>Now that we’ve seen where the visualization is registered, let’s look at the lifecycle that actually drives it.</p><ul><li><strong>create(element)</strong> — called once, when the viz is first mounted. This is where you do one-time setup: creating a root DOM node, setting up your React root, anything that shouldn&#39;t re-run on every query.</li><li><strong>updateAsync(data, element, config, queryResponse, details, done)</strong> — called every time the data, config, or size changes. This is where the actual rendering happens, and critically, you must call done() at the end or Looker will think your viz is still loading.</li></ul><pre>import { createRoot, type Root } from &quot;react-dom/client&quot;;<br>import MyTable from &quot;./components/MyTable&quot;;<br>import type { Config, Option, QueryResponse, Row } from &quot;./types&quot;;<br>import { buildDynamicOptions, staticOptions } from &quot;./options&quot;;<br><br>// Everything our viz object carries: our own state, the lifecycle hooks we<br>// implement, and the helpers Looker injects onto the object at runtime.<br>interface LookerCustomViz {<br>  // Our own state, persisted across updateAsync calls.<br>  root?: Root;<br>  container?: HTMLElement;<br>  _lastDynamicOptions?: string | null;<br><br>  // Injected by Looker at runtime — declare them so TypeScript knows they exist.<br>  trigger?: (event: string, args: unknown) =&gt; void;<br>  addError?: (error: { title: string; message: string }) =&gt; void;<br><br>  // Lifecycle hooks we implement.<br>  create: (element: HTMLElement) =&gt; void;<br>  destroy?: () =&gt; void;<br>  updateAsync: (<br>    data: Row[],<br>    element: HTMLElement,<br>    config: Config,<br>    queryResponse: QueryResponse,<br>    details: unknown,<br>    done: () =&gt; void,<br>  ) =&gt; void;<br>}<br><br>interface LookerVisualizationPlugin {<br>  add: (<br>    viz: LookerCustomViz &amp; {<br>      id: string;<br>      label: string;<br>      options: Record&lt;string, Option&gt;;<br>    },<br>  ) =&gt; void;<br>}<br><br>interface LookerGlobal {<br>  plugins?: { visualizations?: LookerVisualizationPlugin };<br>}<br><br>// Tell TypeScript that `looker` will exist at runtime, injected by the host page.<br>declare global {<br>  var looker: LookerGlobal | undefined;<br>}<br><br>const MyTableViz: LookerCustomViz = {<br>  create(element: HTMLElement) {<br>    // Guard against a second mount on the same element — calling createRoot()<br>    // twice on one node makes React warn and leaks the previous tree.<br>    this.root?.unmount();<br><br>    element.style.position = &quot;relative&quot;;<br>    this.container = element;<br>    this.root = createRoot(element);<br>  },<br><br>  destroy() {<br>    this.root?.unmount();<br>    this.root = undefined;<br>  },<br><br>  updateAsync(<br>    data: Row[],<br>    _element: HTMLElement,<br>    config: Config,<br>    queryResponse: QueryResponse,<br>    _details: unknown,<br>    done: () =&gt; void,<br>  ) {<br>    try {<br>      // Re-register the options config panel only when it actually changed<br>      const dynamicOptions = buildDynamicOptions(config);<br>      const fingerprint = JSON.stringify(dynamicOptions);<br><br>      if (this._lastDynamicOptions !== fingerprint) {<br>        this.trigger?.(&quot;registerOptions&quot;, dynamicOptions);<br>        this._lastDynamicOptions = fingerprint;<br>      }<br><br>      // Looker can call updateAsync before the query has resolved.<br>      if (!queryResponse.fields) {<br>        done();<br>        return;<br>      }<br><br>      this.root?.render(<br>        &lt;MyTable data={data} config={config} queryResponse={queryResponse} /&gt;,<br>      );<br><br>      done();<br>    } catch (err) {<br>      const message = err instanceof Error ? err.message : String(err);<br><br>      // Surfaces the error inside the tile instead of failing silently.<br>      this.addError?.({<br>        title: &quot;Visualization failed to render&quot;,<br>        message,<br>      });<br>      done();<br>    }<br>  },<br>};<br><br>globalThis.looker?.plugins?.visualizations?.add?.({<br>  ...MyTableViz,<br>  id: &quot;my_table&quot;,<br>  label: &quot;My Table&quot;,<br>  options: staticOptions,<br>});</pre><p>Note:</p><ul><li>I usually work with data , queryResponse , and config when generating vizzes, so I used _element and _details because I know they exist, but I don’t need them in this implementation.</li><li>The mental model that helped me: create builds the stage, updateAsync is what runs every time the curtain goes up. Everything reactive — resizing the dashboard tile, changing a filter, editing a color option in the config panel — flows through updateAsync, not create.</li></ul><h3>3. Bundling into One .umd.js File</h3><p>This is where the Library Mode config from Part 2 finally pays off.</p><pre>yarn build</pre><p>Check dist/ — instead of an index.html and a pile of chunked assets, you should see a single file: my-table.umd.js. That&#39;s the entire visualization — React, your table logic, your styles (injected via the CSS plugin) — flattened into one UMD bundle.</p><h3>4. Hosting and Registering on Looker</h3><p>There are two ways to host the bundled file: public cloud storage, or a private git repo mounted directly onto the Looker instance.</p><h4><strong>Option A — Public Cloud Storage (GCS / S3)</strong></h4><p>The simpler option — Looker just needs a public URL it can fetch the .js file from at dashboard load time. It is the fastest to set up, but the compiled bundle (not your source code, just the built UMD file) is publicly accessible.</p><p>After the file is hosted and reachable:</p><ol><li>Go to Admin &gt; Visualizations</li><li>Click “<strong>Add Visualization</strong>”</li><li>Fill ID, Label, and Main (with the bundled file url) and then Save</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*wmjsIMniahQNrDaAK7WcnQ.png" /><figcaption>Register visualizations using public URL</figcaption></figure><p><strong>Note:</strong></p><ul><li>The bundle URL must be served over HTTPS. Also, if you update the .js bundle but don&#39;t see the changes in Looker, browser or server-side caching may be the reason. One simple approach is to include a version in the filename, for example my-table-v3.umd.js, so Looker fetches the updated file.</li></ul><h4><strong>Option B — Private Git Repo Mounted to the Looker Instance</strong></h4><p>You can also push my-table.umd.js to a private repo, a project you are working on or a dedicated repo and mount that repo as one of the projects in your Looker instance. Looker then references the file via that internal path instead of a public bucket URL.</p><p>For example, I have put the bundled file in Looker-viz repository under visualizations/ folder. Then, go to manifest.lkml and add the visualization filepath as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bQWLhc_qQFYjY4rdFWEsmA.png" /></figure><p>This is the setup we use internally — the bundle never touches the public internet.</p><h3>5. The Result on Looker</h3><p>Open any Explore or dashboard tile, switch the visualization type, and your table — colours, config options, everything — should now be rendering against real query data instead of mockData.ts.</p><p>And that’s it: the visualization we built locally is now running inside Looker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kpmwS8v5d1Toi-RhOYCRGw.png" /><figcaption>An example when My Table is rendered on Looker Instance</figcaption></figure><h3>6. From a Simple Example to a Shared Viz Repository</h3><p>The GitHub repository for this series is intentionally stripped down to a single table with basic color-override logic. It is designed to be easy to clone, read, and follow without unnecessary noise.</p><p>Internally, however, we have scaled this exact pattern — the project structure from Part 2 and the create/updateAsync lifecycle from Part 4—into a shared visualization repository. By treating Looker custom vizzes as standard React components, <strong>we can handle dashboard requirements that native Looker charts don’t always support.</strong></p><ul><li><strong>KPI Trees:</strong> hierarchical visualizations that show how a top-level KPI breaks down into its contributing metrics.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dsCXBfsJ4_9RUzrKU9huCQ.png" /><figcaption>KPI Tree using <a href="https://medium.com/u/57d121129b3f">AntV</a>/G6 library</figcaption></figure><ul><li><strong>Custom Rule-Based Formatting:</strong> Applying complex conditional styling with multiple thresholds and criteria, going far beyond a simple status-to-color mapping.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c0VVwXUhlb51BKZiQq87BA.png" /><figcaption>Set up color rule based on value e.g. red if tickets resolved under 15</figcaption></figure><h3>7. How We Develop Custom Vizzes Faster</h3><p>Building the visualization is only part of the challenge. As the number of visualizations grows, the development workflow becomes important too.</p><p>One thing we found with a simple yarn dev setup is that making a small UI change can still mean manually changing mock data, checking different configurations, and repeatedly rebuilding or opening Looker to see how the visualization behaves with different inputs.</p><p>To make this iteration faster, we built VizDevKit — an internal toolkit that wraps each Looker visualization inside Storybook.</p><p>The idea is not to replace testing in Looker. Instead, it gives us a faster feedback loop during development:</p><ul><li><strong>Iterate quickly:</strong> Make UI and visualisation logic changes and see the result immediately without deploying a bundle to Looker.</li><li><strong>Test realistic inputs:</strong> Use mock data shaped like Looker’s queryResponse, data, and config so we can test different scenarios locally.</li><li><strong>Test edge cases:</strong> Easily switch between different data and configurations, such as empty results, different numbers of rows, thresholds, or rule combinations.</li><li><strong>Compare variations:</strong> Preview multiple visualizations or configurations side by side without switching between Looker dashboards.</li></ul><p>There are still things that need to be tested in Looker — especially the integration with the actual Looker Plugin API, real query results, dashboard filters, configuration changes, and how the visualization behaves inside a real dashboard.</p><p>So rather than replacing Looker testing, VizDevKit helps us move more of the iterative UI and logic testing into a faster local feedback loop, and leave Looker for the integration testing that actually requires Looker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YHyr-ZPZtAzsfB-JgWeROQ.png" /><figcaption>Our internal VizDevKit for local development</figcaption></figure><p>While not strictly required for your first custom viz, integrating <strong>Storybook</strong> can make the workflow much easier to manage as the number of visualizations increases.</p><h3>8. What’s Next?</h3><p>This concludes the foundational series — from setting up the project and building the visualization locally to connecting it with Looker and turning the pattern into a shared repository.</p><p>What started as a single custom visualization turned into a broader learning experience. There are still many things involved in building custom visualizations, from advanced configuration and custom font embedding to handling more complex use cases.</p><p>So, there’s still a lot more to explore.</p><p>Thanks for reading all the way to the end! I hope this series gave you a practical look at what it’s like for a Data Engineer to step into the world of Looker custom visualizations.</p><p>If you have any questions, ideas, or feedback, feel free to leave a comment — I’d be happy to hear from you. And if you found the series useful, a clap would be much appreciated. 👏</p><p>You can find the complete example and source code for this series on <a href="https://github.com/ranchana-k/my-looker-viz">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d9c2ccc6725" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When DE assigned to develop Looker Custom Visualization: Part 3 Building the Real Visualization]]></title>
            <link>https://medium.com/@jb.ranchana/when-de-assigned-to-develop-looker-custom-visualization-part-3-building-the-real-visualization-575c5cb7b7d7?source=rss-39d225398681------2</link>
            <guid isPermaLink="false">https://medium.com/p/575c5cb7b7d7</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[looker]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Ranchana Kiriyapong]]></dc:creator>
            <pubDate>Fri, 10 Jul 2026 18:22:33 GMT</pubDate>
            <atom:updated>2026-07-17T12:22:24.183Z</atom:updated>
            <content:encoded><![CDATA[<p>Creating a configurable table style with React</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*ljGqanolMsvMiVyK1w5EHQ.png" /><figcaption>Table visualization with rows colored by health status (green/yellow/red) and measures shown as progress bars</figcaption></figure><p>👉 In Part 2, we set up the project structure and built a complete data pipeline using mock data. If you haven’t read it yet, check it out here:</p><p><a href="https://medium.com/@jb.ranchana/when-de-assigned-to-develop-looker-custom-visualization-part-2-project-structure-19ad7ee17dc7">When DE assigned to develop Looker Custom Visualization: Part 2 Project Structure</a></p><p>We verified that our data flows correctly from mockData.ts through data-transformer.ts into a dummy component. Now it&#39;s time to make it real.</p><p>In this part, we’ll build the actual table visualization with color overriding — the one that Looker’s native charts simply can’t do. By the end, you’ll have a fully working visualization running locally that’s ready to be connected to Looker in Part 4.</p><h3>1. What We’re Building</h3><p>From the table above, each row’s background color changes based on the value of a dimension — in our case, health status. Warning is yellow, Healthy is green, Critical is red. The color rules are configurable, not hardcoded, so users can adjust them directly from the Looker UI without touching the code.</p><p>We’ll break this into three steps:</p><ul><li>Define the color config options in options.ts</li><li>Build the table UI in MyTable.tsx component</li><li>Wire the config into the component</li></ul><h3>2. Defining the Color Config Options</h3><p>Before building the UI, we need to decide how color rules are structured — hardcoded, or driven by config from the Looker UI? We’ll go with the latter, since that’s the whole point of a configurable visualization.</p><p>To support that, we first need types that describe two things: the shape of a single config option (LookerVizOption), and what config will actually look like at runtime (Config). Let&#39;s add these to types.ts:</p><pre>// types.ts<br>// The value types allowed for config options<br>export type ConfigValue = string | number | boolean | string[];<br>export type DisplaySize = &quot;full&quot; | &quot;half&quot; | &quot;third&quot;;<br><br>// The Config object Looker provides based on the options defined<br>export interface Config {<br>  [key: string]: ConfigValue;<br>};<br><br>// The shape of the options object we will use to define our visualization options<br>export interface LookerVizOption {<br> type: &quot;string&quot; | &quot;number&quot; | &quot;boolean&quot; | &quot;array&quot;;<br> label: string;<br> section?: string;<br> order?: number;<br> display?:<br>  | &quot;text&quot;<br>  | &quot;number&quot;<br>  | &quot;color&quot;<br>  | &quot;select&quot;<br>  | &quot;radio&quot;<br>  | &quot;range&quot;<br>  | &quot;divider&quot;;<br> display_size?: DisplaySize;<br> default?: ConfigValue;<br> placeholder?: string;<br> min?: number;<br> max?: number;<br> values?: Array&lt;string | number | { [key: string]: string | number }&gt;;<br>}</pre><p>Options Descriptions:</p><ul><li>type — Type of input value which can be number, string, boolean or array</li><li>label — An option’s name</li><li>section — The tab’s name which this option belongs to. Used when you have many options and would like to categorize your options into several tabs .</li><li>default — The option’s default value</li><li>order — The option’s order in config panel (as per section)</li><li>display_size — The option size in the config panel. The two options with display_size “half” at the consecutive order will be shown as two options in a line.</li></ul><blockquote><strong>Note</strong>: There are many displays of options available, such as radio, select, etc., and also the attributes of each option varies. For example, options with type ‘number’ can have min and max values.</blockquote><p>With these types in place, we can define the actual options. We want two things configurable per rule: which value to match (rule_{i}_value) and which color to apply (rule_{i}_color) — and the number of rules itself should be configurable too, via num_rules.</p><p>Here’s staticOptions (the fixed option, num_rules) and buildDynamicOptions, which reads num_rules and generates a rule_{i}_value / rule_{i}_color pair for each one:</p><pre>// options.ts<br>import type { Config, Option } from &quot;./types&quot;<br><br>export const staticOptions: Record&lt;string, Option&gt; = {<br>    num_rules: {<br>        type: &quot;number&quot;,<br>        label: &quot;Number of Rules&quot;,<br>        section: &quot;Conditional Formatting&quot;,<br>        default: 3,<br>        order: 1,<br>    }<br>}<br>export const buildDynamicOptions = (config: Config) : Record&lt;string, Option&gt; =&gt; {<br>    // Start with your static options<br> const options = { ...staticOptions };<br>    const numRules = Number(config.num_rules) || 0<br><br>    // loop thrugh the number of rules and add dynamic options <br>    // for example, for rule 1 we will add options like rule_1_value and rule_1_color<br>    for (let i = 1; i &lt;= numRules; i++) {<br>        options[`rule_${i}_value`] = {<br>            type: &quot;string&quot;,<br>            label: `Rule ${i} Value`,<br>            section: &quot;Conditional Formatting&quot;,<br>            default: &quot;&quot;,<br>            order: 20 + i,<br>            display_size: &quot;half&quot;<br>        };<br>        options[`rule_${i}_color`] = {<br>            type: &quot;string&quot;,<br>            label: `Color`,<br>            section: &quot;Conditional Formatting&quot;,<br>            default: &quot;#CCCCCC&quot;,<br>            order: 20 + i,<br>            display_size: &quot;half&quot;<br>        };<br>    }<br>    return options;<br>}      </pre><p>Then, prepare mockConfig in mockData.ts — this is what lets us test the color logic locally later, without needing a real Looker instance yet.</p><pre>// mockData.ts<br>export const mockConfig: Config = {<br>    // num_rules: 3,<br>    // rule_1_value: &quot;Healthy&quot;,<br>    // rule_1_color: &quot;#0ab348&quot;,<br>    // rule_2_value: &quot;Warning&quot;,<br>    // rule_2_color: &quot;#ffee54&quot;,<br>    // rule_3_value: &quot;Critical&quot;,<br>    // rule_3_color: &quot;#fb0202&quot;<br>}    </pre><h3>3. Building the Table (MyTable.tsx)</h3><p>Now we replace the dummy JSON.stringify component with a real table. We&#39;ll use plain React — no UI library needed for this one.</p><pre>// MyTable.tsx (Initial Version)<br>import type { Row, QueryResponse, Config } from &#39;../types&#39;<br>import { transformedData } from &#39;../data-transformer&#39;<br><br>type MyTableProps = {<br>  data: Row[]<br>  queryResponse: QueryResponse<br>  config: Config<br>}<br><br>// simple color map (no config) — keys lowercased<br>const COLOR_MAP: Record&lt;string, string&gt; = {<br>  healthy: &#39;#0ab348&#39;,<br>  warning: &#39;#ffee54&#39;,<br>  critical: &#39;#fb0202&#39;,<br>}<br><br>const getColor = (val: unknown) =&gt; {<br>  if (val == null) return &#39;#39a7e5&#39;<br>  const key = String(val).toLowerCase()<br>  return COLOR_MAP[key] ?? &#39;#39a7e5&#39;<br>}<br><br>const getContrastingTextColor = (hex: string) =&gt; {<br>  try {<br>    const c = hex.replace(&#39;#&#39;, &#39;&#39;)<br>    const r = parseInt(c.substring(0, 2), 16)<br>    const g = parseInt(c.substring(2, 4), 16)<br>    const b = parseInt(c.substring(4, 6), 16)<br>    const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255<br>    return luminance &gt; 0.6 ? &#39;#000&#39; : &#39;#fff&#39;<br>  } catch {<br>    return &#39;#000&#39;<br>  }<br>}<br><br>export const MyTable = ({ data = [], queryResponse, config }: MyTableProps) =&gt; {<br>  const dimensions = queryResponse.fields.dimensions || [];<br>  const measures = queryResponse.fields.measures || [];<br>  const rows = transformedData(data)<br><br>  // Calculate max value in order to make progress bar<br>  const maxValues: Record&lt;string, number&gt; = {}<br>  for (const measure of measures) {<br>    maxValues[measure.name] = Math.max(...rows.map(r =&gt; Number(r[measure.name] ?? 0) || 0))<br>  }<br><br>  return (<br>    &lt;div style={{ borderRadius: 6, overflow: &#39;hidden&#39;, background: &#39;#fff&#39; }}&gt;<br>      &lt;table style={{ width: &#39;100%&#39;, borderCollapse: &#39;collapse&#39;, backgroundColor: &#39;#fff&#39;, color: &#39;#111&#39; }}&gt;<br>        &lt;thead&gt;<br>          &lt;tr&gt;<br>            {dimensions.map(dim =&gt; &lt;th key={dim.name} style={{<br>                                textAlign: &#39;left&#39;,<br>                                padding: &#39;8px&#39;,<br>                                borderBottom: &#39;2px solid #e6e6e6&#39;,<br>                                background: &#39;#fafafa&#39;,<br>                                fontWeight: 600,<br>                                whiteSpace: &#39;nowrap&#39;,<br>                                color: &#39;#111&#39;<br>                            }}&gt;{dim.label_short ?? dim.label}&lt;/th&gt;)}<br>            {measures.map(measure =&gt; &lt;th key={measure.name} style={{<br>                                textAlign: &#39;left&#39;,<br>                                padding: &#39;8px&#39;,<br>                                borderBottom: &#39;2px solid #e6e6e6&#39;,<br>                                background: &#39;#fafafa&#39;,<br>                                fontWeight: 600,<br>                                whiteSpace: &#39;nowrap&#39;,<br>                                color: &#39;#111&#39;<br>                            }}&gt;{measure.label_short ?? measure.label}&lt;/th&gt;)}<br>          &lt;/tr&gt;<br>        &lt;/thead&gt;<br>        &lt;tbody&gt;<br>          {rows.map((row, i) =&gt; (<br>            &lt;tr key={i}&gt;<br>              {/* Render Dimensions */}<br>              {dimensions.map(dim =&gt; &lt;td key={dim.name} style={{<br>                                textAlign: &#39;left&#39;,<br>                                padding: &#39;8px&#39;,<br>                                borderBottom: &#39;2px solid #e6e6e6&#39;,<br>                                background: &#39;#fafafa&#39;,<br>                                fontWeight: 600,<br>                                whiteSpace: &#39;nowrap&#39;,<br>                                color: &#39;#111&#39;<br>                            }}&gt;{String(row[dim.name] ?? &#39;&#39;)}&lt;/td&gt;)}<br><br>              {/* Render Measures ด้วยแถบสีพื้นฐาน */}<br>              {measures.map(measure =&gt; {<br>                const numValue = Number(row[measure.name] ?? 0) || 0<br>                const maxVal = maxValues[measure.name] || 1<br>                const pct = Math.max(0, Math.min(100, Math.round((numValue / maxVal) * 100)))<br>                const barWidth = 240<br>                // choose color based on first dimension value for this row (if exists)<br>                const dimVal = dimensions[0] ? row[dimensions[0].name] : undefined<br>                const color = getColor(dimVal)<br>                const textColor = getContrastingTextColor(color)<br>                const insideThreshold = 18<br><br>                return (<br>                  &lt;td key={measure.name} style={{<br>                                textAlign: &#39;left&#39;,<br>                                padding: &#39;8px&#39;,<br>                                borderBottom: &#39;2px solid #e6e6e6&#39;,<br>                                background: &#39;#fafafa&#39;,<br>                                fontWeight: 600,<br>                                whiteSpace: &#39;nowrap&#39;,<br>                                color: &#39;#111&#39;<br>                            }}&gt;<br>                    &lt;div style={{ width: barWidth, height: 28, position: &#39;relative&#39;, background: &#39;transparent&#39;, borderRadius: 6 }}&gt;<br>                      &lt;div style={{ width: `${pct}%`, height: &#39;100%&#39;, background: color, borderRadius: 6, display: &#39;flex&#39;, alignItems: &#39;center&#39;, justifyContent: &#39;flex-end&#39;, padding: &#39;0 12px 0 8px&#39;, boxSizing: &#39;border-box&#39; }}&gt;<br>                        {pct &gt;= insideThreshold &amp;&amp; &lt;span style={{ color: textColor, fontSize: 12, marginRight: 4 }}&gt;{numValue}&lt;/span&gt;}<br>                      &lt;/div&gt;<br>                      {pct &lt; insideThreshold &amp;&amp; (<br>                        &lt;div style={{ position: &#39;absolute&#39;, left: Math.max(barWidth * (pct / 100) + 8, 8), top: 0, height: &#39;100%&#39;, display: &#39;flex&#39;, alignItems: &#39;center&#39; }}&gt;<br>                          &lt;span style={{ color: &#39;#111&#39;, fontSize: 12 }}&gt;{numValue}&lt;/span&gt;<br>                        &lt;/div&gt;<br>                      )}<br>                    &lt;/div&gt;<br>                  &lt;/td&gt;<br>                )<br>              })}<br>            &lt;/tr&gt;<br>          ))}<br>        &lt;/tbody&gt;<br>      &lt;/table&gt;<br>    &lt;/div&gt;<br>  )<br>}</pre><p>If you run yarn dev now, you’ll already see rows colored correctly. But the colors come from a hardcoded map (healthy → green, warning → yellow, critical → red) baked directly into the component. Next, we&#39;ll make this config-driven instead of hardcoded.</p><h3>4. Implementing Color Overriding</h3><p>Let’s replace COLOR_MAP with a function getColorRules that reads from config (the same num_rules, rule_{i}_value, rule_{i}_color we defined in options.ts back in section 2, and revise the getColor function to get color from the input value and rules it’s given.</p><pre>// MyTable.tsx<br><br>// Replace COLOR_MAP with this helper function<br>const getColorRules = (config: Config) =&gt; {<br>    const numRules = Number(config.num_rules) || 0<br>    const rules: Record&lt;string, string&gt; = {}<br><br>    for (let i = 1; i &lt;= numRules; i++) {<br>        const valKey = `rule_${i}_value`<br>        const colKey = `rule_${i}_color`<br>        const value = config[valKey]<br>        const color = config[colKey]<br><br>        if (value !== undefined &amp;&amp; value !== null &amp;&amp; String(value).length &gt; 0) {<br>            rules[String(value).toLowerCase()] = String(color ?? &#39;#CCCCCC&#39;)<br>        }<br>    }<br><br>    return rules<br>}<br><br>// Replace the old getColor function with the new one<br>const getColor = (value: unknown, rules: Record&lt;string, string&gt;) =&gt; {<br>    const key = String(value ?? &#39;&#39;).toLowerCase()<br>    return rules[key] ?? &#39;#CCCCCC&#39;<br>}</pre><p>Two things changed compared to the earlier version:</p><ul><li>getColor no longer just takes val and checks it against a map baked into the code. It now takes rules as a parameter, which means the function isn&#39;t tied to any particular set of colors — whether there are 3 rules or 10, it works the same way.</li><li>The fallback color when nothing matches changed from #39a7e5 (blue) to #CCCCCC (gray), to make it clearer that &quot;no rule has been configured yet.&quot;</li></ul><p>Matching is always case-insensitive (both the keys when building rules and the value being compared), to avoid subtle bugs when data coming from Looker has inconsistent casing like Healthy, healthy, HEALTHY.</p><h4>Here is the final version of MyTable.tsx</h4><pre>import type { Row, QueryResponse, Config } from &#39;../types&#39;<br>import { transformedData } from &#39;../data-transformer&#39;<br><br>type Props = {<br>    data: Row[]<br>    queryResponse: QueryResponse,<br>    config: Config<br>}<br><br>const getColorRules = (config: Config) =&gt; {<br>    const numRules = Number(config.num_rules) || 0<br>    const rules: Record&lt;string, string&gt; = {}<br><br>    for (let i = 1; i &lt;= numRules; i++) {<br>        const valKey = `rule_${i}_value`<br>        const colKey = `rule_${i}_color`<br>        const value = config[valKey]<br>        const color = config[colKey]<br><br>        if (value !== undefined &amp;&amp; value !== null &amp;&amp; String(value).length &gt; 0) {<br>            rules[String(value).toLowerCase()] = String(color ?? &#39;#CCCCCC&#39;)<br>        }<br>    }<br><br>    return rules<br>}<br><br>const getColor = (val: unknown, rules: Record&lt;string, string&gt;) =&gt; {<br>    if (val == null) return &#39;#CCCCCC&#39;<br>    const key = String(val).toLowerCase()<br>    return rules[key] ?? &#39;#CCCCCC&#39;<br>}<br><br>const getContrastingTextColor = (hex: string) =&gt; {<br>    try {<br>        const c = hex.replace(&#39;#&#39;, &#39;&#39;)<br>        const r = parseInt(c.substring(0, 2), 16)<br>        const g = parseInt(c.substring(2, 4), 16)<br>        const b = parseInt(c.substring(4, 6), 16)<br>        // Perceived luminance<br>        const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255<br>        return luminance &gt; 0.6 ? &#39;#000&#39; : &#39;#fff&#39;<br>    } catch (e) {<br>        return &#39;#000&#39;<br>    }<br>}<br><br>export const MyTable = ({ data = [], queryResponse, config }: Props) =&gt; {<br><br>    const dimensions = queryResponse.fields.dimensions || [];<br>    const measures = queryResponse.fields.measures || [];<br>    const colorRules = getColorRules(config || {})<br>    // use transformed data (optionally sorted) as the source of truth for rendering<br>    const rows = transformedData(data)<br>    // Compute per-measure max values for relative bar scaling from transformed rows<br>    const maxValues: Record&lt;string, number&gt; = {}<br>    for (const measure of measures) {<br>        maxValues[measure.name] = Math.max(<br>            ...rows.map(r =&gt; Number(r[measure.name] ?? 0) || 0)<br>        )<br>    }<br><br>    return (<br>        &lt;div style={{ borderRadius: 6, overflow: &#39;hidden&#39;, background: &#39;#fff&#39; }}&gt;<br>        &lt;table style={{ width: &#39;100%&#39;, borderCollapse: &#39;collapse&#39;, backgroundColor: &#39;#fff&#39;, color: &#39;#111&#39; }}&gt;<br>            &lt;thead&gt;<br>                &lt;tr&gt;<br>                    {/* Dimension headers */}<br>                    {dimensions.map(dim =&gt; (<br>                        &lt;th<br>                            key={dim.name}<br>                            style={{<br>                                textAlign: &#39;left&#39;,<br>                                padding: &#39;8px&#39;,<br>                                borderBottom: &#39;2px solid #e6e6e6&#39;,<br>                                background: &#39;#fafafa&#39;,<br>                                fontWeight: 600,<br>                                whiteSpace: &#39;nowrap&#39;,<br>                                color: &#39;#111&#39;<br>                            }}<br>                        &gt;<br>                            {dim.label_short ?? dim.label ?? dim.name}<br>                        &lt;/th&gt;<br>                    ))}<br><br>                    {/* Measure headers */}<br>                    {measures.map(measure =&gt; (<br>                        &lt;th<br>                            key={measure.name}<br>                            style={{<br>                                textAlign: &#39;left&#39;,<br>                                padding: &#39;8px&#39;,<br>                                borderBottom: &#39;2px solid #e6e6e6&#39;,<br>                                background: &#39;#fafafa&#39;,<br>                                fontWeight: 600,<br>                                whiteSpace: &#39;nowrap&#39;,<br>                                color: &#39;#111&#39;<br>                            }}<br>                        &gt;<br>                            {measure.label_short ?? measure.label ?? measure.name}<br>                        &lt;/th&gt;<br>                    ))}<br>                &lt;/tr&gt;<br>            &lt;/thead&gt;<br><br>                &lt;tbody&gt;<br>                {rows.map((row, i) =&gt; (<br>                    &lt;tr key={i}&gt;<br>                        {/* Dimension cells */}<br>                        {dimensions.map(dim =&gt; {<br>                            const val = row[dim.name]<br>                            const displayValue = String(val ?? &#39;&#39;)<br>                            return (<br>                                &lt;td<br>                                    key={dim.name}<br>                                    style={{ padding: &#39;8px&#39;, borderBottom: &#39;1px solid #eee&#39; }}<br>                                &gt;<br>                                    {displayValue}<br>                                &lt;/td&gt;<br>                            )<br>                        })}<br><br>                        {/* Measure cells — each renders a horizontal bar */}<br>                        {measures.map(measure =&gt; {<br>                            const raw = row[measure.name]<br>                            const numValue = Number(raw ?? 0) || 0<br>                            const displayValue = String(raw ?? numValue)<br><br>                            // choose color based on first dimension value for this row (if exists)<br>                            const dimVal = dimensions[0] ? row[dimensions[0].name] : undefined<br>                            const color = getColor(dimVal, colorRules)<br><br>                            const maxVal = maxValues[measure.name] || 1<br><br>                            const safeMax = maxVal || 1<br>                            const pct = Math.max(0, Math.min(100, Math.round((numValue / safeMax) * 100)))<br>                            const barWidth = 240<br>                            const textColor = getContrastingTextColor(color)<br>                            const insideThreshold = 18 // percent threshold to keep label inside bar<br><br>                            return (<br>                                &lt;td<br>                                    key={measure.name}<br>                                    style={{ padding: &#39;8px&#39;, borderBottom: &#39;1px solid #eee&#39;, overflow: &#39;visible&#39;, whiteSpace: &#39;nowrap&#39; }}<br>                                &gt;<br>                                    &lt;div style={{ display: &#39;flex&#39;, alignItems: &#39;center&#39;, gap: 8 }}&gt;<br>                                        &lt;div style={{ width: barWidth, height: 28, background: &#39;transparent&#39;, borderRadius: 6, overflow: &#39;visible&#39;, position: &#39;relative&#39; }}&gt;<br>                                            &lt;div style={{ width: `${pct}%`, height: &#39;100%&#39;, background: color, display: &#39;flex&#39;, alignItems: &#39;center&#39;, justifyContent: &#39;flex-end&#39;, padding: &#39;0 12px 0 8px&#39;, boxSizing: &#39;border-box&#39;, borderRadius: 6 }}&gt;<br>                                                {pct &gt;= insideThreshold &amp;&amp; (<br>                                                    &lt;span style={{ color: textColor, fontSize: 12, marginRight: 4 }}&gt;{displayValue}&lt;/span&gt;<br>                                                )}<br>                                            &lt;/div&gt;<br>                                            {pct &lt; insideThreshold &amp;&amp; (<br>                                                &lt;div style={{ position: &#39;absolute&#39;, left: Math.max(barWidth * (pct / 100) + 8, 8), top: 0, height: &#39;100%&#39;, display: &#39;flex&#39;, alignItems: &#39;center&#39; }}&gt;<br>                                                    &lt;span style={{ color: &#39;#111&#39;, fontSize: 12 }}&gt;{displayValue}&lt;/span&gt;<br>                                                &lt;/div&gt;<br>                                            )}<br>                                        &lt;/div&gt;<br>                                    &lt;/div&gt;<br>                                &lt;/td&gt;<br>                            )<br>                        })}<br>                    &lt;/tr&gt;<br>                ))}<br>            &lt;/tbody&gt;<br>        &lt;/table&gt;<br>        &lt;/div&gt;<br>    )<br>}</pre><h3>5. Testing Locally</h3><p>Run yarn dev and select <strong>My Table</strong> — the table should now be colored according to the rules defined in staticOptions (the default is 3 empty rules, so everything will show up gray until values are filled in).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*ZY4ThA1zWIctQBmb4haTwg.png" /></figure><p>Try uncommenting mockConfig to match what a user would actually fill in inside the Looker UI, for example:</p><pre>export const mockConfig: Config = {<br>    num_rules: 3,<br>    rule_1_value: &quot;Healthy&quot;,<br>    rule_1_color: &quot;#0ab348&quot;,<br>    rule_2_value: &quot;Warning&quot;,<br>    rule_2_color: &quot;#ffee54&quot;,<br>    rule_3_value: &quot;Critical&quot;,<br>    rule_3_color: &quot;#fb0202&quot;,<br>}</pre><p>Then check that rows where health_status.status is Critical turn red, Warning turns yellow, and Healthy turns green — exactly what we set out to build at the start of this article.</p><p>We can try changing values in mockConfig back and forth — swap colors, change which values should match, increase or decrease num_rules — and watch the UI update instantly without restarting the dev server. This is the feedback loop we set up back in Part 2 paying off: no Looker instance needed, no deploy, and you can fully validate the coloring logic locally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*o6ZcqqqwiO1Fz2zB_Y7-Gg.png" /><figcaption>The table after changing rule_3_color to orange</figcaption></figure><h3>Key Takeaway</h3><p>In this part, we turned a static data pipeline into a real, user-facing visualization. The core design decision was keeping color logic completely separate from table structure: the table component only knows how to render dimensions, measures, and bars — it has no opinion about what “healthy” or “critical” should look like. That opinion lives entirely in config, which means stakeholders can reshape the visualization&#39;s behavior from the Looker UI without ever touching the code again.</p><p>👉 In Part 4, we’ll close that gap: bundling the visualization, hosting it, and registering it in Looker Admin so this same table runs live on a real Looker dashboard.</p><h3><strong>Going Further</strong></h3><p>The same config-driven pattern extends naturally beyond exact-match dimension values. For example, you could support rules on measures too — “color this bar red if revenue is below 0” or “green if growth is greater than 20%” — without changing how the table renders at all, only how rules are matched.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*r3JKugelp85CYKt0H4DQqQ.png" /><figcaption>Configuration with more complex rules (rendered on Local)</figcaption></figure><p>If this was useful, a clap means a lot as encouragement — and if you don’t want to miss Part 4, follow along here on Medium.</p><p>Thanks for reading, and see you in Part 4!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=575c5cb7b7d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When DE assigned to develop Looker Custom Visualization: Part 2 Project Structure]]></title>
            <link>https://medium.com/@jb.ranchana/when-de-assigned-to-develop-looker-custom-visualization-part-2-project-structure-19ad7ee17dc7?source=rss-39d225398681------2</link>
            <guid isPermaLink="false">https://medium.com/p/19ad7ee17dc7</guid>
            <category><![CDATA[looker]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Ranchana Kiriyapong]]></dc:creator>
            <pubDate>Wed, 15 Apr 2026 08:50:23 GMT</pubDate>
            <atom:updated>2026-04-18T10:21:31.364Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Building a solid foundation for Looker custom visualizations with local development and mock data</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bGXIWzgMKwDQdrtJ" /><figcaption>Photo by <a href="https://unsplash.com/@dengxiangs?utm_source=medium&amp;utm_medium=referral">Deng Xiang</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Now that we understand the high-level workflow, it’s time to build the foundation. While I could just give you a repository to clone, I strongly recommend <strong>building it from scratch</strong> using yarn create vite. This approach ensures you understand how each piece of the puzzle fits together, which is crucial for troubleshooting complex visuals later on.</p><p>👉 <em>If you haven’t read Part 1 where we break down how Looker custom visualizations work under the hood, you can check it out here:</em></p><p><a href="https://medium.com/@jb.ranchana/when-de-assigned-to-develop-looker-custom-visualization-part-1-how-it-works-cd5fc2579151">When DE assigned to develop Looker Custom Visualization: Part 1 How It works</a></p><h3>Why Vite?</h3><p>For this tutorial, we’ll use Vite simply because it’s easy to set up and works well out of the box. It gives us a fast feedback loop during development without much configuration, which is exactly what we need at this stage. <strong>You can use other bundlers as long as they can produce a single JavaScript bundle for Looker.</strong></p><h3>1. Initializing the Project</h3><p>Before we start, make sure you have the following installed:</p><ul><li>Node.js (v18+) — <a href="https://nodejs.org/en/download">download here</a></li><li>Yarn — install via npm: npm install --global yarn</li></ul><p>Once ready, start the project:</p><pre>yarn create vite my-looker-viz --template react-ts</pre><p><em>(Note: I recommend </em><strong><em>TypeScript</em></strong><em> for better type safety when handling Looker’s complex JSON data).</em></p><p>To test how it works on local, you can run the following command.</p><pre>yarn dev</pre><p>You will see the initial UI from the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yubTXwxWomXgvVHZUBmc9g.png" /><figcaption>The initial index.html template on localhost</figcaption></figure><h3>2. The Recommended Project Structure</h3><p>To keep your project scalable (especially when you start adding more metrics or complex logic), I suggest the following organization:</p><pre>my-looker-viz/<br>src/<br>├── common/                # Utility และ Types for all Visualization<br>│   ├── helpers.ts         # Shared helper funtions<br>│   └── ...               <br>├── visualizations/        # Main folder for each visualization<br>│   └── my-table/          # A specific folder for your viz <br>│       ├── components/    # UI Components for only this viz<br>│       │     └── MyTable.tsx    # Main UI component for this visualization<br>│       ├── App.tsx        # React local Entry Point <br>│       ├── data-transformer.ts # Logic for transforming Looker data into needed format<br>│       ├── mockData.ts    # Mockup data for running test on local<br>│       ├── options.ts     # Options or Config for this viz<br>│       └── looker-viz.ts  # Used for Looker API<br>│   <br>├── index.tsx<br>├── App.tsx               # Root application for local preview           <br>└── setupTests.ts<br>├── index.html            # Template for Rendering on local host<br>├── vite.config.ts        # Setting for Build (bundling)<br>├── package.json<br>└── ... (Other config files)</pre><h3>3. Playing with Your Data</h3><p>Before connecting to a real Looker instance, the smartest move is to <strong>mock your data locally</strong>. This decouples your development loop from Looker entirely — no waiting for dashboard loads, no fighting with credentials, just pure component development speed.</p><h4>3.1 Understanding Looker’s Data Shape</h4><p>Looker passes data to your custom visualization through two key objects:</p><ul><li><strong>data</strong> — An array of row objects, where each key maps to a field name</li><li><strong>queryResponse</strong> — Metadata about the query: dimension names, measure names, field definitions, etc.</li></ul><p><em>(Note: There is also a </em><em>config object for user-configurable options, which we will cover in a later part.)</em></p><p>A typical payload for an incident tracking report looks like this:</p><pre>[<br>  {<br>    &quot;incidents.status&quot;: { &quot;value&quot;: &quot;Warning&quot; },<br>    &quot;incidents.count&quot;:  { &quot;value&quot;: 10,    &quot;rendered&quot;: &quot;10&quot; }<br>  },<br>  {<br>    &quot;incidents.status&quot;: { &quot;value&quot;: &quot;Healthy&quot; },<br>    &quot;incidents.count&quot;:  { &quot;value&quot;: 2500,  &quot;rendered&quot;: &quot;2,500&quot; }<br>  },<br>  {<br>    &quot;incidents.status&quot;: { &quot;value&quot;: &quot;Critical&quot; },<br>    &quot;incidents.count&quot;:  { &quot;value&quot;: 2,     &quot;rendered&quot;: &quot;2&quot; }<br>  }<br>]</pre><p><strong>The Looker API Pattern: Objects over Primitives</strong></p><p>If you are used to flat JSON, Looker’s response might seem unusual. Notice the pattern: <strong>every cell is a wrapped object, not a raw value.</strong></p><p>For every field, you will find a value key. However, for <strong>numeric values</strong> (like counts or currency), Looker also includes a rendered key:</p><ul><li><strong>value</strong>: The raw data (e.g., 2500). Use this for calculations, logic, or sorting in your code.</li><li><strong>rendered</strong>: The UI-ready string (e.g., &quot;2,500&quot;). Use this for display to ensure the formatting matches what users see in the Looker Explore UI.</li></ul><p>By returning objects instead of plain primitives, the API preserves the formatting logic defined in your LookML layer. This allows your custom visualization to display data exactly as intended — complete with thousand separators or currency symbols — without any manual string manipulation on the frontend.</p><h4>3.2 Defining Your Types</h4><p>Before writing any data logic, we define the shape of Looker’s data in types.ts. This way every file that follows speaks the same language.</p><p>Create src/visualizations/my-table/types.ts:</p><pre>// src/visualizations/my-table/types.ts<br><br>// A single cell value from Looker<br>export interface Cell {<br>  value:     string | number | boolean | null  // raw value for calculation<br>  rendered?: string                            // formatted string for display e.g. &quot;4,215&quot; or &quot;$138,540&quot;<br>  html?:     string                            // raw HTML string e.g. &quot;&lt;a href=&#39;...&#39;&gt;text&lt;/a&gt;&quot;<br>  links?:    Array&lt;{ label: string; url: string }&gt; // drill links from looker<br>}<br><br>// A single row: field name → Cell<br>// e.g. { &quot;orders.status&quot;: { value: &quot;complete&quot; }, &quot;orders.count&quot;: { value: 4215, rendered: &quot;4,215&quot; } }<br>export type Row = Record&lt;string, Cell&gt;<br><br>// Field metadata from queryResponse<br>export interface Field {<br>  name:  string  // Looker field name e.g. &quot;orders.status&quot;<br>  label: string  // display name e.g. &quot;Orders Status&quot;<br>  type:  string  // field type e.g. &quot;string&quot;, &quot;count&quot;, &quot;sum&quot;<br>}<br><br>// The queryResponse object Looker provides<br>export interface QueryResponse {<br>  fields: {<br>    dimensions: Field[]  // non-aggregated fields e.g. status, category<br>    measures:   Field[]  // aggregated fields e.g. count, revenue<br>  }<br>  pivots: unknown[]      // pivot fields if any, empty array if none<br>}</pre><p>With these types defined, TypeScript will catch field name typos and null-value bugs at <strong>compile time</strong> — not after deployment.</p><blockquote>Please see a reference for differences between type and interface in TypeScript <a href="https://blog.logrocket.com/types-vs-interfaces-typescript/">https://blog.logrocket.com/types-vs-interfaces-typescript/</a></blockquote><h4>3.3 Setting Up Your Mock Data</h4><p>Create src/visualizations/my-table/mockData.ts:</p><pre>import type { Row, QueryResponse } from &#39;./types&#39;<br><br>export const mockData: Row[] = [<br>  {<br>    &quot;incidents.health&quot;: { value: &quot;Warning&quot;,  rendered: &quot;Warning&quot;  },<br>    &quot;incidents.count&quot;:  { value: 8,          rendered: &quot;8&quot;        },<br>  },<br>  {<br>    &quot;incidents.health&quot;: { value: &quot;Healthy&quot;,  rendered: &quot;Healthy&quot;  },<br>    &quot;incidents.count&quot;:  { value: 25,         rendered: &quot;25&quot;       },<br>  },<br>  {<br>    &quot;incidents.health&quot;: { value: &quot;Critical&quot;, rendered: &quot;Critical&quot; },<br>    &quot;incidents.count&quot;:  { value: 2,          rendered: &quot;2&quot;        },<br>  },<br>]<br><br>export const mockQueryResponse: QueryResponse = {<br>  fields: {<br>    dimensions: [<br>      { name: &quot;incidents.health&quot;, label: &quot;Health&quot;,         type: &quot;string&quot; },<br>    ],<br>    measures: [<br>      { name: &quot;incidents.count&quot;,  label: &quot;Incident Count&quot;, type: &quot;count&quot;  },<br>    ],<br>  },<br>  pivots: [],<br>}</pre><blockquote><strong><em>Note:</em></strong><em> Field names follow Looker’s </em><em>view_name.field_name convention. If you&#39;re unsure of the exact names, you can inspect </em><em>queryResponse.fields via the browser Console — we&#39;ll cover that in Part 3 when we connect to a live dashboard.</em></blockquote><h4>3.4 Transforming Data for Your Component</h4><p>Raw Looker data is not UI-ready. data-transformer.ts is where you bridge that gap — and more importantly, where all Looker-specific knowledge stays contained.</p><p>Create src/visualizations/my-table/data-transformer.ts:</p><pre>import type { Row } from &#39;./types&#39;<br><br>export const transformedData = (data: Row[]): Record&lt;string, unknown&gt;[] =&gt; {<br>    if (!data) return [];<br>    return data.map(row =&gt; {<br>        const newRow: Record&lt;string, unknown&gt; = {};<br>        for (const key in row) {<br>            newRow[key] = row[key].value;<br>        }<br>        return newRow;<br>    });<br>};<br></pre><p><strong>Note:</strong> This transformer extracts value only. If your component needs the formatted string (e.g. &quot;$138,540&quot; instead of 138540.25), you can use row[key].rendered ?? row[key].value instead — which falls back to value if rendered isn&#39;t available.</p><h3>4. Build a Simple Component</h3><p>Before wiring everything together, we need a component to render into. Start with a <strong>dummy version</strong> — no styling, no logic, just enough to verify data is flowing correctly.</p><p>Create src/visualizations/my-table/components/MyTable.tsx:</p><pre>type Props = {<br>  data: Record&lt;string, unknown&gt;[]<br>}<br><br>export const MyTable = ({ data }: Props) =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;h3&gt;My Table&lt;/h3&gt;<br>      &lt;pre&gt;{JSON.stringify(data, null, 2)}&lt;/pre&gt;<br>    &lt;/div&gt;<br>  )<br>}</pre><p>We’ll replace this with the real visualization in Part 3. For now, JSON.stringify is our best friend for verifying that data is flowing correctly before committing to any UI.</p><h4>4.1 Wiring It Into App.tsx</h4><p>Up until this point, everything lives inside the visualization itself. Now, we need a simple way to preview it during development.</p><p>Create src/visualizations/my-table/App.tsx:</p><pre>// src/visualizations/my-table/App.tsx<br>import { mockData } from &#39;./mockData&#39;<br>import { transformedData } from &#39;./data-transformer&#39;<br>import { MyTable } from &#39;./components/MyTable&#39;<br><br>function MyTableApp() {<br>  const transformed = transformedData(mockData)<br><br>  return (<br>    &lt;div style={{ padding: &#39;2rem&#39; }}&gt;<br>      &lt;MyTable data={transformed} /&gt;<br>    &lt;/div&gt;<br>  )<br>}<br><br>export default MyTableApp</pre><h4>4.2 Creating a Local Preview App</h4><p>To preview your visualization locally, we need to register it in the root application.</p><p>Update src/App.tsx to include your visualization:</p><pre>// src/App.tsx<br>import { useState } from &#39;react&#39;<br>import MyTableApp from &#39;./visualizations/my-table/App&#39;<br><br>// Add more ids as you create new visualizations<br>type VizId = &#39;table&#39;<br><br>const visualizations: { id: VizId; name: string; description: string }[] = [<br>  { id: &#39;table&#39;, name: &#39;My Table&#39;, description: &#39;Categorical bar with color overriding&#39; },<br>  // Add new viz here<br>]<br><br>function App() {<br>  const [selected, setSelected] = useState&lt;VizId | null&gt;(null)<br><br>  if (selected === &#39;table&#39;) {<br>    return (<br>      &lt;div&gt;<br>        &lt;button onClick={() =&gt; setSelected(null)}&gt;← Back&lt;/button&gt;<br>        &lt;MyTableApp /&gt;<br>      &lt;/div&gt;<br>    )<br>  }<br><br>  return (<br>    &lt;div style={{ padding: &#39;40px&#39;, maxWidth: &#39;800px&#39;, margin: &#39;0 auto&#39;, width: &#39;100%&#39; }}&gt;<br>      &lt;h1 style={{ marginBottom: &#39;10px&#39; }}&gt;Looker Visualizations Library&lt;/h1&gt;<br>      &lt;p style={{ color: &#39;#666&#39;, marginBottom: &#39;40px&#39; }}&gt;Select a visualization to preview&lt;/p&gt;<br>      &lt;div style={{ display: &#39;grid&#39;, gap: &#39;20px&#39; }}&gt;<br>        {visualizations.map(viz =&gt; (<br>          &lt;div<br>            key={viz.id}<br>            onClick={() =&gt; setSelected(viz.id)}<br>            style={{ padding: &#39;20px&#39;, backgroundColor: &#39;#fff&#39;, borderRadius: &#39;8px&#39;, boxShadow: &#39;0 2px 4px rgba(0,0,0,0.1)&#39;, cursor: &#39;pointer&#39; }}<br>          &gt;<br>            &lt;h3 style={{ margin: &#39;0 0 8px 0&#39;, color: &#39;#000&#39; }}&gt;{viz.name}&lt;/h3&gt;<br>            &lt;p style={{ margin: 0, color: &#39;#666&#39;, fontSize: &#39;14px&#39; }}&gt;{viz.description}&lt;/p&gt;<br>          &lt;/div&gt;<br>        ))}<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  )<br>}<br><br>export default App</pre><h4>4.3 Running Your App</h4><p>Run yarn dev to see the new Index page as following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fULkfd22adlXnrVy4vTmnw.png" /></figure><p>Select My Table from the index page, and you should see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OqK_7RnYfUPMWwieSPpAYw.png" /></figure><pre>[<br>  { &quot;incidents.health&quot;: &quot;Warning&quot;,  &quot;incidents.count&quot;: 8  },<br>  { &quot;incidents.health&quot;: &quot;Healthy&quot;,  &quot;incidents.count&quot;: 25 },<br>  { &quot;incidents.health&quot;: &quot;Critical&quot;, &quot;incidents.count&quot;: 2  }<br>]</pre><p>If the data looks correct here, your entire data layer is working — transformer, mock data, and component are all connected. You’re ready to build the real UI in Part 3.</p><h3>Key Takeaway</h3><ul><li>Building a Looker custom visualization isn’t about UI first — it’s about <strong>data flow first</strong>.</li><li>In this part, we built a complete data pipeline without writing a single line of UI logic:</li></ul><pre>mockData.ts  →  data-transformer.ts  →  MyTable.tsx<br>(Looker shape)    (extracts value)      (renders data)</pre><p>Each layer has one job. Keep it that way and debugging becomes much easier — especially when your Looker data shape changes down the line.</p><p>If the data flows correctly here, the rest becomes just UI.</p><p>In the next part, we’ll turn this data pipeline into a real user-facing visualization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19ad7ee17dc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When DE assigned to develop Looker Custom Visualization: Part 1 How It works]]></title>
            <link>https://medium.com/@jb.ranchana/when-de-assigned-to-develop-looker-custom-visualization-part-1-how-it-works-cd5fc2579151?source=rss-39d225398681------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd5fc2579151</guid>
            <category><![CDATA[looker]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[custom-visualization]]></category>
            <dc:creator><![CDATA[Ranchana Kiriyapong]]></dc:creator>
            <pubDate>Tue, 10 Feb 2026 16:03:00 GMT</pubDate>
            <atom:updated>2026-04-18T10:15:01.780Z</atom:updated>
            <content:encoded><![CDATA[<p>Create Looker Custom Visualization using react.js + recharts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MIGAqM6peXpTmxV5" /><figcaption>Photo by <a href="https://unsplash.com/@karepesinde?utm_source=medium&amp;utm_medium=referral">Cht Gsml</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Last year, our team decided to migrate our visualization tool to <strong>Looker</strong>. The main reason? It integrates natively with <strong>BigQuery</strong>, our data warehouse, making our workflow much smoother and faster.</p><p>As a part of the team, I was assigned to run a <strong>PoC (Proof of Concept)</strong> on Looker visualizations. To be honest, I hit a roadblock almost immediately: Looker’s out-of-the-box charts didn’t quite fit our existing dashboards.</p><p>Our project requires more “complex” visuals. We’re talking about mixed-type visualizations that Looker’s standard library just can’t handle — like a table containing a donut chart with two lines of key metrics floating perfectly in the middle, or categorical bar with color overriding.</p><p>We needed to study the feasibility of this part of migration, and well… <strong>tada! It was me.</strong></p><p>Now, full disclosure: I’m a Data Engineer, a bit of a “jack of all trades,” but my frontend experience was pretty much non-existent. My only real encounter with JavaScript was through some basic <strong>Google Apps Script</strong>.</p><p>I started searching for use cases or tutorials on Looker Custom Visualizations, but I found… <strong>almost nothing.</strong> The community content was sparse, and the official documentation felt like a puzzle with missing pieces.</p><h3>The Breakthrough</h3><p>Through a lot of effort (and a fair share of trial and error), I eventually made it work.</p><p>In this series of articles, I’ll walk you through what’s actually needed for custom visualizations and provide a high-level overview of how to build them. I won’t lie — I won’t tell you it’s “easy,” but I can show you the path I took to make it possible and understandable.</p><h3>How does Looker Custom Visualizations actually work?</h3><p>Before we dive into the code, let’s talk about how a bunch of JavaScript becomes a functional chart in Looker. Think of it as a bridge between your custom logic and Looker’s data engine. There are 2 main components that make the magic happen:</p><h4>1. Registration: The Handshake</h4><p>It’s a small configuration in the Looker Admin panel that tells Looker, <em>“Hey, I have a new type of chart here, and you can find the logic at this URL.”</em> This is where you define your visualization’s identity, unique ID, and label.</p><h4>2. Looker API: The Real-time Messenger</h4><p>This is the magic part. Looker provides a <strong>Visualization API</strong>. Whenever you change a filter, select a new dimension, or run a query, Looker doesn’t just refresh a page; it passes the data in a clean JSON format directly to your browser, where your custom code is waiting.</p><p>It’s like Looker is saying, <em>“Here’s the fresh data and the user’s preferred settings, now go draw the viz!”</em> — -</p><h3>The Setup Workflow in a Nutshell</h3><p>To bring your custom visualization (like my <strong>Categorical Bar Color Overriding</strong> table) to life, the workflow typically follows this 4-step cycle:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IECWfpwLVzyy250vBjwk2A.png" /><figcaption>Custom Visualization Development workflow</figcaption></figure><ol><li><strong>Develop:</strong> Build your chart locally using libraries like <strong>React</strong> and <strong>Recharts</strong>. This is where you define the logic for how bars should change color based on their category.</li><li><strong>Bundle:</strong> Use a bundler (like Vite) to package your code into a single <strong>.umd.js</strong> file. This ensures Looker can load everything it needs from one place.</li><li><strong>Host:</strong> Upload that file to a Cloud Storage bucket (GCS/S3) or host it within your Looker project. Just make sure Looker has the permissions to “reach” that URL.</li><li><strong>Register &amp; Use:</strong> Point Looker to your hosted URL in the Admin settings. Once registered, your custom viz will appear as an option in the Explore’s visualization bar, ready for your stakeholders to use.</li></ol><p>Curious about what the final result looks like? Here’s a sneak peek of the custom dashboard that native Looker couldn’t build<strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a_wxuXoVU30tLmSP4Rh6rQ.png" /></figure><p>In the <strong>next article</strong>, we’ll get our hands dirty. I’ll walk you through the <strong>project structure</strong> for building a robust Looker custom visualization and show you exactly <strong>how to develop</strong> the logic behind this table — even if you’re coming from a Data Engineering background with zero frontend experience like me.</p><p><strong>Continue to Part 2</strong> →</p><p><a href="https://medium.com/@jb.ranchana/when-de-assigned-to-develop-looker-custom-visualization-part-2-project-structure-19ad7ee17dc7">When DE assigned to develop Looker Custom Visualization: Part 2 Project Structure</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd5fc2579151" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BigQuery Pricing: Query-Level Cost Attribution for Editions vs. On-Demand]]></title>
            <link>https://medium.com/@jb.ranchana/bigquery-pricing-query-level-cost-attribution-for-editions-vs-on-demand-bd3164fe1c48?source=rss-39d225398681------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd3164fe1c48</guid>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[finops]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[Ranchana Kiriyapong]]></dc:creator>
            <pubDate>Sat, 13 Dec 2025 06:49:16 GMT</pubDate>
            <atom:updated>2025-12-13T07:00:44.448Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Stop guessing which pricing model is cheaper.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zr-dNYtzex4vvmTOJ8GHpQ.png" /><figcaption>Bigquery On-Demand vs Edition (AI-generated Image)</figcaption></figure><p>Google BigQuery offers two main pricing models: <strong>On-Demand</strong> and <strong>Capacity Editions (Reservations)</strong>. Choosing the right one has a direct impact on your analytics cost efficiency.</p><p>Many users assume Reservations are only for massive, 24/7 enterprises with flat-rate contracts. However, with the new BigQuery Editions, <strong>you can set your baseline slots to zero.</strong> This means you effectively pay “On-Demand” for compute capacity — autoscaling up when a query hits, and down when it finishes.</p><h4><strong>The Problem: </strong>Cost Attribution</h4><p>With On-Demand, you know exactly how much a query costs ($ per TB). With Reservations, you pay for the <em>duration</em> the slots are active.</p><p>But here is the catch: Autoscalers have a “cool-down” period. Even if you have zero commitment, the slots often stay active for up to 60 seconds after your query finishes. If you simply calculate the query execution time, you miss this “Tail Cost,” making your reservation calculations artificially low.</p><p>This article walks through:</p><ol><li>BigQuery Pricing Models Overview</li><li>The Challenge in Tracking Reservation Cost by Query</li><li>The Solution: A Query to Match Slots vs. Job ID</li></ol><h3>1. BigQuery Pricing Models Overview</h3><h4>1.1 On-Demand (Per TB Processed)</h4><p>This is the default model. You pay based on the volume of bytes your query scans.</p><ul><li><strong>Pros:</strong> No configuration needed. Ideal for spiky or unpredictable workloads.</li><li><strong>Cost:</strong> Approx. <strong>$6.25 per TB</strong> (varies by region, for example, $8.4375 per TB for asia-southeast1)</li></ul><h4>1.2 Reservations (Editions &amp; Autoscaling)</h4><p>Instead of paying for data scanned, you pay for the compute capacity (Slots) used to process the data.</p><ul><li><strong>The “Zero-Baseline” Advantage:</strong> You can configure your reservation with a minimum of <strong>0 slots</strong>.</li><li><strong>How it works:</strong> When you run a query, BigQuery automatically scales up slots. When the query finishes, it scales back down.</li><li><strong>The Hidden Cost:</strong> Autoscaling isn’t instantaneous. BigQuery often keeps slots active for a short “cool-down” period (up to 60 seconds) after a job finishes to handle potential follow-up queries.</li></ul><p><strong>The Decision:</strong> Is it cheaper to pay for the TB scanned, or is it cheaper to rent the slots for the execution time + the cool-down overhead?</p><h3>2. The Challenge in Tracking Reservation Cost by Query</h3><p>To compare costs, we need to join the <strong>Job</strong> (the query) to the <strong>Reservation Usage</strong> (the bill). BigQuery provides two system tables for this:</p><ol><li><strong>region-asia-southeast1.INFORMATION_SCHEMA.JOBS_BY_PROJECT</strong> This table contains key columns such as:</li></ol><ul><li>job_id</li><li>start_time</li><li>end_time</li><li>query</li><li>total_bytes_billed</li><li>reservation_id(nullable)</li></ul><p><strong>2. </strong><strong>region-asia-southeast1.INFORMATION_SCHEMA.RESERVATIONS_TIMELINE_BY_PROJECT</strong></p><p>This table tracks slot usage granularly. It generates <strong>one record per minute, per reservation</strong>.</p><ul><li>period_start: The timestamp (minute-level granularity).</li><li>reservation_name: The specific reservation using the slots.</li><li>slot_seconds: Total slot capacity consumed.</li><li>project_id</li><li>period_autoscale_slot_seconds</li><li>per_second_details (struct)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*sp2aKhMYPXVtRmuwjlhW6w.png" /><figcaption>A BigQuery data table showing period_start and period_autoscale_slot_seconds to illustrate minute-level cost.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-9bmsEvaJEHfNxq_G4-LEw.png" /><figcaption>The per_second_details <strong>STRUCT</strong> column contains nested fields, including the autoscale_current_slots array which breaks down slot usage by second.</figcaption></figure><p><strong>The Disconnect:</strong> The reservation timeline table shows us how many slots were active, but it doesn’t explicitly tell us <em>which</em> job_id kept them active.</p><p>If you strictly join these tables based on start_time and end_time, you will successfully calculate the cost of the query <em>while it was running</em>. However, you will fail to capture the <strong>Autoscaling Cool-down</strong>. These &quot;ghost slots&quot; appear in your bill but have no active job running during that second.</p><p>To fix this, we need a <strong>“Tail Match”</strong> logic.</p><h3>3. The Solution: A Query to Match Slots vs. Job ID</h3><p>To accurately calculate the cost, my query below performs the following steps:</p><ol><li><strong>Fetch Job Data:</strong> Get the query details.</li><li><strong>Fetch Slot Timeline:</strong> Get the minute-by-minute slot usage.</li><li><strong>Base Join:</strong> Match times where the job was actively running.</li><li><strong>Tail Match (Crucial):</strong> If we find slots that are active but have no running job, we look back 1 minute. If a job finished within that window, we attribute those slots to that job as idle_overhead.</li><li><strong>Allocate:</strong> If multiple queries run at once, we share the cost proportionally.</li></ol><h4>The SQL Query</h4><p><em>Replace the following placeholders with your actual values:</em></p><ul><li>your-project-id</li><li>region-asia-southeast1 and :asia-southeast1.</li><li><strong>Cost Multipliers:</strong> Update 0.0735 (Slot Price) and 8.4375 (On-Demand Price) in the final SELECT statement to match the pricing for your specific region.</li></ul><blockquote><strong>Note:</strong> This analysis requires historical data from actual reservation usage. You must have run queries under a BigQuery Edition (Standard, Enterprise, or Enterprise Plus) to generate the necessary logs in the RESERVATIONS_TIMELINE table. If you are currently purely On-Demand, you will need to enable an Edition and run a pilot workload first.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cb80b9da1b77c6a6dea3e1f7a019d9a/href">https://medium.com/media/1cb80b9da1b77c6a6dea3e1f7a019d9a/href</a></iframe><h3>⚠️ Important Warnings</h3><ol><li><strong>Date Filtering:</strong> The jobs subquery should always be filtered with a specific date range (e.g., creation_time). Scanning INFORMATION_SCHEMA over long periods can process a lot of GB and increase your analysis costs.</li><li><strong>Timezone Sync:</strong> I wrapped the date with DATE(period_start, &#39;America/Los_Angeles&#39;) as billed_date. This ensures the cost drops into the same daily bucket as your Google Cloud billing report. Google uses Pacific Time to calculate billing periods for all customers globally (see documentation).</li><li><strong>Null On-Demand Costs:</strong> If you see null for on-demand costs, it might mean the query result was cached (free), or you may lack permissions to view the total_bytes_billed for a specific table in the query.</li><li><strong>Isolated Project:</strong> Ideally, run your pilot on an isolated project linked to a dedicated Reservation. If multiple projects share the same Reservation, slot costs are distributed across them, which can make the A/B cost comparison less precise.</li></ol><h3>Interpreting the Results</h3><p>When you run this query, you will get a row per job_id. You can now make a data-driven decision:</p><ul><li><strong>If </strong><strong>est_ondemand_cost_usd &lt; </strong><strong>est_reservation_cost_usd:</strong> Stick to On-Demand. This usually happens for small, infrequent queries that trigger the autoscaler. The 60-second idle_overhead often makes the &quot;startup cost&quot; of the reservation too high for the value delivered.</li><li><strong>If </strong><strong>est_reservation_cost_usd &lt; </strong><strong>est_ondemand_cost_usd:</strong> Move to Editions. This happens with &quot;heavy&quot; queries that process TBs of data but run efficiently on slots.</li></ul><p>By accounting for the idle_overhead, you ensure you aren&#39;t underestimating the true cost of autoscaling from zero.</p><h3>Conclusion</h3><p>Many factors affect BigQuery costs, such as <strong>data model</strong>, query frequency, complexity, and concurrency. Because of this, purely theoretical calculations based on On-Demand logs often fail to predict the true impact of Autoscaling and Slot Contention.</p><p>The most accurate strategy is to <strong>run a pilot</strong>. Enable BigQuery Editions for a specific project or timeframe, and then use this query to audit the results.</p><p>By comparing the actual est_reservation_cost (including the hidden idle overhead) against the equivalent est_ondemand_cost, you can scientifically validate whether the switch saved you money—or if On-Demand is a better fit for your specific workload.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd3164fe1c48" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding HyperLogLog: A Visual Workflow]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@jb.ranchana/understanding-hyperloglog-a-visual-workflow-39d78886a003?source=rss-39d225398681------2"><img src="https://cdn-images-1.medium.com/max/2600/0*J9cVsqz3Gpx0LFho" width="4120"></a></p><p class="medium-feed-snippet">A Step by Step Explanation of How HyperLogLog Works</p><p class="medium-feed-link"><a href="https://medium.com/@jb.ranchana/understanding-hyperloglog-a-visual-workflow-39d78886a003?source=rss-39d225398681------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@jb.ranchana/understanding-hyperloglog-a-visual-workflow-39d78886a003?source=rss-39d225398681------2</link>
            <guid isPermaLink="false">https://medium.com/p/39d78886a003</guid>
            <category><![CDATA[hyperloglog]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <dc:creator><![CDATA[Ranchana Kiriyapong]]></dc:creator>
            <pubDate>Sun, 19 Oct 2025 17:42:37 GMT</pubDate>
            <atom:updated>2025-10-19T17:42:37.808Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[HyperLogLog++: Efficiently Approximate COUNT(DISTINCT) Across Modern Data Platforms]]></title>
            <link>https://medium.com/@jb.ranchana/hyperloglog-efficiently-approximate-count-distinct-across-modern-data-platforms-6592b742b6b6?source=rss-39d225398681------2</link>
            <guid isPermaLink="false">https://medium.com/p/6592b742b6b6</guid>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[hyperloglog]]></category>
            <category><![CDATA[count-distinct]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Ranchana Kiriyapong]]></dc:creator>
            <pubDate>Tue, 23 Sep 2025 13:08:00 GMT</pubDate>
            <atom:updated>2025-09-24T07:50:07.672Z</atom:updated>
            <content:encoded><![CDATA[<p>How to speed up distinct counts on massive datasets with minimal cost — examples in BigQuery</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*drEKpvMJSuV8pgUs" /><figcaption>Photo by <a href="https://unsplash.com/@blakewisz?utm_source=medium&amp;utm_medium=referral">Blake Wisz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In many data engineering projects, tracking <strong>key metrics</strong> such as unique users, unique members, or the number of transactions over a period is essential for business insights. One common challenge is calculating <strong>COUNT DISTINCT</strong> on large datasets. For example, counting unique customers per day is straightforward, but aggregating the total number of unique customers across multiple days can be tricky. There might be 2 unique customers on Day 1 and 3 on Day 2, yet the combined total could range from 3 to 5.</p><p>Many modern data warehouses and databases provide the APPROX_COUNT_DISTINCT function, which returns <strong>an approximate count of unique values</strong> with a<strong> slight trade-off in accuracy</strong>. While reading the documentation, I discovered that it is powered by the <strong>HyperLogLog++ algorithm</strong>, which piqued my interest.</p><p>HyperLogLog++ stores counts as compact <strong>“sketches”</strong> at an aggregated level (e.g., by date) and merges them efficiently to estimate total unique items.</p><p>In this article, I’ll provide a brief overview of HyperLogLog++, discuss advanced usage, and share experiments tracking its performance and error rates.</p><h3>Table of Contents</h3><ul><li><a href="#4b8a">Understanding HyperLogLog++ (HLL)</a></li><li><a href="#060d">Using </a><a href="#060d">APPROX_COUNT_DISTINCT() for simple cases</a></li><li><a href="#165d">Advanced HLL Functions</a></li><li><a href="#1ec4">Experiments: Comparing Exact vs. Approximate Counts</a></li><li><a href="#ec19">HyperLogLog in Other Data Warehouses</a></li><li><a href="#7a4e">Conclusion</a></li></ul><h3>Understanding HyperLogLog++ (HLL)</h3><p><strong>HyperLogLog++ (HLL)</strong> is a clever statistical technique that helps estimate the number of unique items <strong>without storing all the raw data</strong>.</p><p>Instead of keeping every single value, HLL creates a small <strong>“sketch”</strong> of the dataset. This sketch can then be merged with others to estimate the total unique count across different subsets of data.</p><p>The logic behind this technique can seem complicated, so here’s a simplified overview of what happens when we use <strong>HyperLogLog++</strong>:</p><ol><li><strong>Registers as cameras</strong><br>The function creates multiple <strong>register units</strong>, which you can imagine as cameras (default is 15 units).</li><li><strong>Hashing each data item</strong><br>Each data item (like a user ID) is hashed into a random bit sequence, for example 0011010. Imagine each hash as a “person” entering a camera’s view. Because the hash is random, the number of leading zeros acts like a rare signal — <strong>more zeros mean the person is unusual</strong>.</li><li><strong>Tracking max leading zeros per camera</strong><br>Each register/camera keeps track of the <strong>maximum number of leading zeros</strong> it has seen. Higher numbers indicate rare events, which likely correspond to more unique items.</li><li><strong>Creating a sketch for aggregation</strong><br>The function summarizes each camera’s max zeros into a <strong>sketch</strong> at the desired aggregation level (e.g., daily). Now you have a sketch for each day.</li><li><strong>Merging sketches</strong><br>When analyzing multiple days of data, the sketches can be merged by taking the <strong>max for each register</strong>. For example:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*iMviMSJt4A5tpKpK61BZig.png" /><figcaption>Example of a 4-register HyperLogLog sketch.</figcaption></figure><p><strong>6. Estimating the approximate unique count</strong><br>Finally, HLL uses a <strong>statistical formula</strong> to convert the pattern of max zeros into an <strong>approximate count of unique items</strong>. Conceptually:</p><ul><li>Buckets with higher max zeros indicate rarer items, which suggest more unique items overall.</li><li>Buckets with lower max zeros indicate fewer unique items.<br> Using the merged sketch above, HLL applies this formula to estimate the total number of unique items, for example around 6.</li></ul><p><em>Note: The max zeros themselves are not the count; they are used as a signal in the formula to estimate the unique count.</em></p><blockquote>For readers interested in a deeper understanding of HyperLogLog and HyperLogLog++, Shavin Anjitha’s article provides a clear and practical overview: <a href="https://shavinanjitha.medium.com/hyperloglog-precision-estimation-for-massive-data-streams-b9118445aaa7?utm_source=chatgpt.com">HyperLogLog: Precision Estimation for Massive Data Streams</a></blockquote><h3>Using APPROX_COUNT_DISTINCT() for simple cases</h3><p>In BigQuery, you might have already used or at least heard of the function APPROX_COUNT_DISTINCT(). This is the simplest way to apply HyperLogLog++ without dealing with advanced functions.</p><p>When you use this function, BigQuery automatically sets the precision (i.e., the number of registers used in the sketch) to the default value of 15. This means you don’t need to configure anything manually — you just call the function.</p><p><strong>For illustration, here’s how it works in BigQuery:</strong>.</p><pre><br><br>SELECT<br>    event_date,<br>    event_name,<br>    APPROX_COUNT_DISTINCT(user_pseudo_id) as user_counts<br>FROM<br>  `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*` <br>WHERE<br>  _TABLE_SUFFIX BETWEEN &#39;20210101&#39; AND &#39;20210131&#39; <br>GROUP BY event_date, event_name<br>ORDER BY event_date</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NB10r-rb9PMqb-jWUCY9Zw.png" /><figcaption>The Result Using APPROX_COUNT_DISTINCT() Grouped by event_date and event_name</figcaption></figure><p><strong>Note:</strong></p><p>The function APPROX_COUNT_DISTINCT() returned numeric value. The result cannot be reused or merged across different aggregations. If you need to build hierarchical aggregations (daily → weekly → monthly), you will need to re-run on the raw data or switch to advanced HLL functions.</p><h3>Advanced HLL Functions in BigQuery</h3><p>When you need more flexibility than APPROX_COUNT_DISTINCT(), BigQuery provides <strong>HyperLogLog++ functions</strong> that allow you to build, store, and merge sketches directly. These are especially useful if:</p><ul><li>You want to <strong>adjust the precision</strong> of the sketch (higher precision = lower error, larger storage).</li><li>You need to <strong>store intermediate sketches</strong> (e.g., daily) and combine them later into weekly/monthly/yearly aggregates.</li><li>You want to <strong>reduce costs</strong> by avoiding repeated scans of the full raw dataset.</li></ul><p>The main HyperLogLog++ functions in BigQuery are:</p><ul><li><strong>HLL_COUNT.INIT(expr, precision)</strong> → Creates a sketch from a column value (e.g., user_id) and returns it as a byte array.</li><li><strong>HLL_COUNT.MERGE(sketches)</strong> → Combines multiple sketches and returns the <strong>approximate number of unique values</strong>.</li></ul><h4>Step 1: Generate daily sketches</h4><pre>SELECT<br>    event_date,<br>    event_name,<br>    HLL_COUNT.INIT(user_pseudo_id, 15) as users_sketch<br>FROM<br>  `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*` <br>WHERE<br>  _TABLE_SUFFIX BETWEEN &#39;20210101&#39; AND &#39;20210131&#39; <br>GROUP BY event_date, event_name<br>ORDER BY event_date</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gztz8J7BxM2jR2pVZ_XMWg.png" /><figcaption>The Result after Grouping with HLL_COUNT.INIT()</figcaption></figure><blockquote>Notice that users_sketch is returned as <strong>BYTES</strong>. This sketch can later be aggregated without scanning the raw data again.</blockquote><h4><strong>Step 2: Merge sketches to get monthly approximate counts</strong></h4><pre>WITH daily_event as (<br>  SELECT<br>    event_date,<br>    event_name,<br>    HLL_COUNT.INIT(user_pseudo_id, 15) as users_sketch<br>FROM<br>  `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*` <br>WHERE<br>  _TABLE_SUFFIX BETWEEN &#39;20210101&#39; AND &#39;20210131&#39; <br>GROUP BY event_date, event_name<br>ORDER BY event_date)<br><br>SELECT <br>  FORMAT_DATE(&#39;%Y%m&#39;, PARSE_DATE(&#39;%Y%m%d&#39;, event_date)) as yearmonth, -- Convert string to date, then extract YYYYMM<br>  event_name,<br>  HLL_COUNT.MERGE(users_sketch) as user_approx_counts<br>FROM daily_event<br>GROUP BY FORMAT_DATE(&#39;%Y%m&#39;, PARSE_DATE(&#39;%Y%m%d&#39;, event_date)), event_name<br>ORDER BY event_name</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1F2dzzRn9W7fEGlcQ7gVg.png" /><figcaption>The Approximate Count Value Grouped by yearmonth and event_name</figcaption></figure><blockquote>Compared to APPROX_COUNT_DISTINCT(), you now have the flexibility to <strong>aggregate sketches across different levels</strong> (daily → monthly). The results remain consistent because HyperLogLog++ is <strong>deterministic</strong>, and we used a precision of 15 — the same default as APPROX_COUNT_DISTINCT().</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*253mKRI5kHrG3_Uvej67ag.png" /><figcaption>Re-aggregated results using APPROX_COUNT_DISTINCT(). Approximate counts match HLL merge output.</figcaption></figure><h4>Adjusting Precision in HyperLogLog++</h4><p>You can change the precision value when using HLL_COUNT.INIT to reduce error rate. To see the expected error for each precision setting, refer to the <a href="https://cloud.google.com/bigquery/docs/sketches#precision_hll">BigQuery documentation</a>.</p><h3>Experiments: Comparing Exact vs. Approximate Counts</h3><p>To evaluate performance and cost trade-offs, I ran experiments on table, partitioned by date.</p><p>The goal was to compare five different methods:</p><ol><li><strong>No aggregation + Exact</strong> — Exact distinct counts using COUNT(DISTINCT …)</li><li><strong>No aggregation + Approx (Precision 15)</strong> — Approximate counts using APPROX_COUNT_DISTINCT() with default precision of 15, applied directly to raw data. This method uses the same data volume as the exact method to allow fair comparison.</li><li><strong>Aggregation + Approx (Precision 15)</strong> — Using HyperLogLog++ with precision 15 on pre-aggregated sketches</li><li><strong>Aggregation + Approx (Precision 20)</strong> — Using HyperLogLog++ with precision 20 on pre-aggregated sketches</li><li><strong>Aggregation + Approx (Precision 24)</strong> — Using HyperLogLog++ with precision 24 on pre-aggregated sketches</li></ol><h4>Observations</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uj0uUcRJiov_-gdZmhavnQ.png" /><figcaption>Performance Test</figcaption></figure><ul><li>Runtime increases significantly with larger datasets. Exact COUNT(DISTINCT) scales poorly for high-volume queries, while approximate methods (including APPROX_COUNT_DISTINCT and aggregated HLL sketches) reduce runtime considerably.</li><li>For large (L) queries without aggregation, switching to APPROX_COUNT_DISTINCT() improved runtime by 46%, from 69.33s to 37.54s.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9mbVT2VvznXy4az10uEyRQ.png" /><figcaption>Cost Test</figcaption></figure><ul><li>For cost (measured as billed bytes in GiB), the trend mirrors runtime. Approximate counts without aggregation still incurred high cost because they scanned the same volume of raw data as exact counts.</li><li>Using HLL sketches aggregated at the daily level reduced the amount of scanned data, leading to significantly lower query cost. As expected, higher precision slightly increased cost but also improved accuracy.</li></ul><blockquote><strong>Note:</strong> Figures represent averages from multiple experiments and have been adjusted for confidentiality.</blockquote><h4>Accuracy</h4><p>To evaluate the accuracy of HyperLogLog++ (HLL) for approximating distinct counts, we tested three representative cases with different data volumes. The goal was to compare exact counts against approximate counts using HLL sketches with varying precision values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jmf5R_O8AgRKnpmC6E_w9A.png" /><figcaption>Accuracy Test</figcaption></figure><blockquote>Note: Scaled down and anonymized to protect confidential data.</blockquote><h4>Will the Approximation Value Change?</h4><p>One common question about using HyperLogLog++ is whether the approximation result changes each time you run the query.</p><p>The short answer is: <strong>No, it won’t change — as long as the underlying data and precision do not change.</strong></p><p>That’s because HyperLogLog++ is a deterministic algorithm.</p><ul><li>The hashing step always produces the same bit patterns for the same input values.</li><li>The registers will therefore store the same maximum leading zeros across runs.</li><li>The final statistical formula will always return the same approximate count.</li></ul><p>The result will only change if:</p><ul><li>The underlying dataset is updated (new, changed, or removed rows), or</li><li>You explicitly change the precision parameter in HLL_COUNT.INIT().</li></ul><p>So if your dataset is static, re-running the same HLL query will always return the same approximation.</p><h3>HyperLogLog in Other Data Warehouses</h3><p>Although this article focuses on BigQuery, it’s worth noting that HyperLogLog (and its improved version HyperLogLog++) is widely adopted across many data platforms:</p><ul><li><strong>Snowflake</strong> → HLL_ACCUMULATE and HLL_ESTIMATE</li><li><strong>Amazon Redshift</strong> → hll_create_sketch and hll_cardinality</li><li><strong>databricks</strong> → hll_sketch_agg and hll_sketch_estimate</li><li><strong>PostgreSQL</strong> (via extensions like postgres-hll)</li></ul><p>The core idea is the same: using compact HLL sketches to estimate distinct counts efficiently. So even if you’re not on BigQuery, the concept and benefits apply across platforms.</p><h3>Conclusion</h3><p>HyperLogLog++ is a powerful technique for approximating distinct counts on massive datasets. While it trades off a tiny bit of accuracy, the performance and cost savings are often well worth it — especially for dashboards and analytical queries on large tables.</p><p>One key point to remember: <strong>results are deterministic</strong> and will remain the same across runs as long as the underlying data and precision do not change.</p><p>Finally, it’s important to <strong>communicate the approximation and potential error margin</strong> to stakeholders. Even if the difference is usually small (&lt;1%), making users aware of the approximation helps maintain trust in the metric.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6592b742b6b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generate QR Codes with Custom Colors and Logos in Google Sheets]]></title>
            <link>https://medium.com/@jb.ranchana/how-to-generate-qr-codes-in-google-sheets-step-by-step-guide-b5c1df5b987f?source=rss-39d225398681------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5c1df5b987f</guid>
            <category><![CDATA[qr-code]]></category>
            <category><![CDATA[qrcodescanner]]></category>
            <category><![CDATA[qrcodegenerator]]></category>
            <category><![CDATA[appsheet]]></category>
            <dc:creator><![CDATA[Ranchana Kiriyapong]]></dc:creator>
            <pubDate>Thu, 28 Aug 2025 01:41:04 GMT</pubDate>
            <atom:updated>2025-09-08T02:19:30.913Z</atom:updated>
            <content:encoded><![CDATA[<p>Learn how to create bulk QR Codes directly in Google Sheets using Image-Charts. Perfect for teachers, businesses, and data managers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yHPD50fKX3purvcq" /><figcaption>Photo by <a href="https://unsplash.com/@risto_kokkonen?utm_source=medium&amp;utm_medium=referral">Risto Kokkonen</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>QR Codes are everywhere these days — on menus, flyers, event tickets, and even product packaging. They make sharing and accessing information quick and effortless. But did you know you can also <strong>create QR Codes directly in Google Sheets</strong>?</p><p>This is especially useful for teachers, businesses, or anyone managing bulk data like links, invoices, or product catalogs. In this guide, you’ll learn:</p><ul><li>Why the old Google Chart API is no longer reliable</li><li>How to generate QR Codes step by step in Google Sheets</li><li>How to bulk-generate QR Codes for multiple entries</li><li>How to test your QR Codes easily using <a href="https://qrpeek.me/?utm_source=chatgpt.com">QRPeek.me</a></li></ul><h3>Why You Shouldn’t Use the Old Google Chart API</h3><p>Google’s Chart API (chart.googleapis.com) was once a simple way to generate QR Codes through a URL. However, it has been deprecated, meaning it could stop working anytime without warning. If you still rely on it, you risk broken QR Codes in your documents or workflows.</p><p><strong>Better alternative?</strong> Use <a href="https://image-charts.com/chart?utm_source=chatgpt.com">Image-Charts</a>, a service that works seamlessly with Google Sheets and lets you create QR Codes on the fly using URL parameters. No extra software needed.</p><h3>Step-by-Step: Generate QR Codes in Google Sheets</h3><ol><li><strong>Prepare your data in Google Sheets</strong></li></ol><p>Add your URLs or text into column A of your Google Sheet (for example, cell A2).</p><p><strong>2. Create a basic QR Code formula</strong></p><p>In the cell where you want the QR Code to appear, paste this formula:</p><pre>=IMAGE(&quot;https://image-charts.com/chart?chs=150x150&amp;cht=qr&amp;choe=UTF-8&amp;chl=&quot;&amp;ENCODEURL(A2))</pre><blockquote><strong>Tip:</strong> Sometimes the QR Code image doesn’t reload when the URL changes because of Google Sheets’ cache.<br> To fix this, you can add a “cachebuster” parameter that changes every time the sheet recalculates:</blockquote><pre>=IMAGE(&quot;https://image-charts.com/chart?chs=150x150&amp;cht=qr&amp;choe=UTF-8&amp;chl=&quot;&amp;ENCODEURL(A2)&amp;&quot;&amp;cb=&quot;&amp;RAND())</pre><p><strong>Explanation of parameters:</strong></p><ul><li>chs=150x150 → QR Code size (width x height in pixels)</li><li>cht=qr → Chart type = QR Code</li><li>choe=UTF-8 → (Optional) How to encode the data in the QR code. Currently only UTF-8 is supported .</li><li>chl= → Data to encode (URL, text, or numbers)</li><li>ENCODEURL(A2) → Encodes the content from cell A2 for safe URL usage</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*FzaIUxslK8FhhdAGSiaQqw.png" /><figcaption>QR Code Generated</figcaption></figure><p>Note:</p><ul><li>You may see a warning asking for access. This is because Image-Charts is an API that generates the QR Code image. Click “Allow access” to allow.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TK8Dz3i8_Uh8EKNJjUZBEA.png" /><figcaption>Click Allow Access</figcaption></figure><p>📌 Tip: Adjust the cell height and width in Google Sheets to match the QR Code size so it displays clearly.</p><p><strong>3. Bulk-generate multiple QR Codes</strong></p><p>Drag the formula down the column, and you’ll instantly generate QR Codes for every row of data. Perfect for invoices, product lists, or classroom materials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*3HMtR32TycNQFVk4pyhWBg.png" /><figcaption>The result after dragging down the formula</figcaption></figure><h3>Customize QR Codes: Color, Error Correction, Margin, and Logo</h3><p>Image-Charts lets you customize QR Codes even further with additional parameters:</p><p><strong>1. Change QR Code Color</strong><br> Use the icqrf=&lt;color&gt; parameter to set the foreground color of your QR Code. (For background color, click <a href="https://documentation.image-charts.com/qr-codes/">here</a>)</p><ul><li>&lt;color&gt; should be in <strong>RRGGBB</strong> or <strong>RRGGBBAA</strong> hexadecimal format.</li><li>Default is <strong>000000</strong> (black).</li></ul><p><strong>Example:</strong></p><pre>=IMAGE(&quot;https://image-charts.com/chart?chs=150x150&amp;cht=qr&amp;choe=UTF-8&amp;icqrf=F47B2C&amp;chl=&quot;&amp;ENCODEURL(A2)&amp;&quot;&amp;cb=&quot;&amp;RAND()&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7QcLOuRJcDhd9qReDOgiRg.png" /><figcaption>QR Code with Customised Color</figcaption></figure><p><strong>2. Adding a Logo in the Center of Your QR Code</strong></p><p>You may have noticed that many QR Codes include a small logo in the middle — like a brand icon or event badge. This works because QR Codes are designed with <strong>error correction</strong>. In simple terms, they have “backup data” built in. Even if part of the code is covered, the scanner can still read it correctly.</p><p>That’s why you can safely place a small logo in the center over your QR Code without breaking it.</p><blockquote><strong>Tip:</strong> Keep your logo small and always test it before sharing or printing.</blockquote><p>You can add a small logo by placing an image to the middle of the cell then make your QR Code more robust by adjusting its <strong>error correction level</strong> using the parameter</p><pre>chld=&lt;error_correction_level&gt;|&lt;margin&gt;</pre><p><strong>Error Correction Levels:</strong></p><ul><li><strong>L</strong> — Default. Recovers up to 7% data loss (best for plain QR Codes).</li><li><strong>M</strong> — Recovers up to 15% data loss.</li><li><strong>Q</strong> — Recovers up to 25% data loss (recommended if adding a small logo).</li><li><strong>H</strong> — Recovers up to 30% data loss (best for larger logos or heavy print use).</li></ul><p>👉 Higher levels make your QR Code more resistant to damage or obstruction but slightly reduce how much data you can store.</p><p><strong>Margin:</strong></p><ul><li>This sets the white border around your QR Code (measured in rows, not pixels).</li><li>Default is <strong>4</strong>. Smaller margins may cause scanning problems, so avoid going too low.</li></ul><p><strong>Example:</strong></p><pre>=IMAGE(&quot;https://image-charts.com/chart?chs=150x150&amp;cht=qr&amp;choe=UTF-8&amp;icqrf=F47B2C&amp;chl=&quot;&amp;ENCODEURL(A2)&amp;&quot;&amp;chld=&quot;&amp;ENCODEURL(&quot;Q|4&quot;)&amp;&quot;&amp;cb=&quot;&amp;RAND())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YK3yb-gcKkAcQWYWOdYf_w.png" /><figcaption>QR Code with a Logo inside</figcaption></figure><p>From the previous example, I tried generating a QR Code with a small logo in the center <strong>without changing the error correction level</strong>. It didn’t scan properly because the data was very short and simple. After I changed the error correction level to <strong>Q</strong>, the QR Code worked perfectly.</p><p><strong>Tip:</strong></p><ul><li>When your QR Code contains only a small amount of data (like a short URL or simple text), the scanner may have difficulty reading it if part of the code is covered by a logo.</li><li>Using a higher error correction level (Q or H) makes the QR Code more robust and ensures it can still be scanned even with a small logo in the center.</li></ul><h3>How to Test Your QR Codes</h3><p>Before sharing or printing your QR Codes, always test them. You have two simple options:</p><ol><li><strong>Scan with your phone</strong> — quick and easy.</li><li>Use <a href="https://qrpeek.me/?utm_source=chatgpt.com">QRPeek.me</a> – just upload the QR Code image and verify it leads to the correct URL or text. This is especially handy if you’re testing multiple codes or working from a desktop.</li></ol><p>By testing, you ensure every QR Code is scannable and error-free — whether used digitally or in print.</p><h3>Tips and Best Practices</h3><ul><li><strong>Keep URLs short</strong> → Shorter links = cleaner, easier-to-scan QR Codes. Use a URL shortener if needed.</li><li><strong>Choose the right size</strong> → For printing, use at least 300x300 pixels for reliable scans.</li><li><strong>Organize your sheet</strong> → Add one column for content and another for QR Codes so everything stays clear.</li><li><strong>Always test before sharing</strong> → Even if the formula looks right, scanning confirms it works as you expected.</li></ul><h3>Using QR Codes with AppSheet (Optional)</h3><p>If you’re already using Google Sheets with AppSheet (Google’s no-code platform), QR Codes can make your apps even more powerful. For example:</p><ul><li><strong>Attendance / Check-in apps</strong> → Scan QR Codes from event tickets or classroom rosters. (See how to enable barcode scanning in AppSheet <a href="https://support.google.com/appsheet/answer/10106618?hl=en#supported-scanners">here</a>)</li><li><strong>Inventory management</strong> → Generate QR Codes for product IDs in Google Sheets, then scan them inside AppSheet to update stock.</li><li><strong>Document workflows</strong> → Link QR Codes to invoices or purchase orders for quick retrieval.</li></ul><p>Because the QR Codes are generated directly inside your Google Sheet, they integrate smoothly into any AppSheet app built on that sheet. This is especially useful if you want to move from spreadsheets to a mobile-friendly tool without extra coding.</p><h3>Conclusion</h3><p>Generating QR Codes in Google Sheets is simple, scalable, and perfect for bulk tasks. While the old Google Chart API is deprecated, <strong>Image-Charts</strong> offers a reliable replacement. With just one formula, you can create QR Codes for any text, URL, or number directly inside your spreadsheet.</p><p>Once generated, quickly verify them with your phone or via <a href="https://qrpeek.me/?utm_source=chatgpt.com">QRPeek.me</a> to ensure they’re ready for printing, sharing, or embedding into documents.</p><p>Whether you’re a teacher, business owner, or content creator, this method will save you time and keep your workflow organized. And if you want a <strong>fast, no-spreadsheet QR Code reader right now</strong>, try it instantly at <a href="https://qrpeek.me/?utm_source=chatgpt.com"><strong>QRPeek.me</strong></a><strong> </strong>— it’s free and ready to use.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5c1df5b987f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Scan QR Codes Online — Tips for Mobile and Desktop]]></title>
            <link>https://medium.com/@jb.ranchana/how-to-scan-qr-codes-online-tips-for-mobile-and-desktop-e534b7f82a12?source=rss-39d225398681------2</link>
            <guid isPermaLink="false">https://medium.com/p/e534b7f82a12</guid>
            <category><![CDATA[qrcodescanner]]></category>
            <category><![CDATA[qr-code]]></category>
            <category><![CDATA[qrcodereader]]></category>
            <dc:creator><![CDATA[Ranchana Kiriyapong]]></dc:creator>
            <pubDate>Mon, 25 Aug 2025 12:10:23 GMT</pubDate>
            <atom:updated>2025-08-28T01:53:10.042Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Scan or Read QR Codes on PC Safely (No App Needed)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zqKQ2MMU8QFahh1h" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_source=medium&amp;utm_medium=referral">Brett Jordan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Need to scan a QR code but don’t want to install any app? Whether it’s from a PDF, an image, or multiple screenshots, this guide shows the fastest and safest way to read QR codes online from any device. Using your phone isn’t always convenient, especially when you’re working on a computer — that’s where browser-based QR scanning comes in. We’ll walk you through how to scan QR Codes online, highlight common challenges, and share practical tips for both desktop and mobile users.</p><h3>Why Scanning QR Codes Can Be Tricky</h3><p>Most modern smartphones have built-in QR Code scanners, and many camera or messaging apps detect codes automatically. However, there are situations where mobile scanning isn’t enough:</p><ul><li><strong>Embedded in documents:</strong> QR Codes inside PDFs, Word documents, or images sometimes cannot be scanned directly from your phone.</li><li><strong>Copying content:</strong> Sometimes you need the QR Code content on your computer, like URLs, contact info, or product details.</li><li><strong>Multiple QR Codes at once:</strong> Scanning several codes quickly is easier on a desktop or with a browser-based tool.</li></ul><p>Even tech-savvy users encounter these challenges, especially students, remote workers, or anyone dealing with digital content regularly.</p><h3>Tips and Use Cases for Browser-Based QR Scanning</h3><p>Browser-based QR scanners are fast, safe, and don’t require any software installation. Here’s how to make the most of them:</p><p><strong>Scan QR Codes from PDFs or screenshots:</strong> Save QR Codes as separate image files and upload them to an online scanner.</p><p><strong>Batch scanning:</strong> Quickly process multiple QR Codes at once, which is more organized than scanning each with a phone.</p><p><strong>Copy content efficiently:</strong> Extract URLs, text, or contact info directly into desktop apps without taking a photo first.</p><p><strong>Common scenarios:</strong></p><ul><li><strong>Event tickets or boarding passes:</strong> Scan codes in emails or PDFs before printing or sharing.</li><li><strong>Invoices or receipts:</strong> Many digital invoices include QR Codes for payments or verification.</li><li><strong>Product manuals or guides:</strong> Access tutorials, videos, or support pages linked via QR Codes.</li></ul><p><strong>Safety tip:</strong> Stick to reputable online scanners to avoid malware or suspicious downloads.</p><p>Browser-based scanning fills the gaps where mobile devices aren’t practical, making it a convenient solution for work, study, or managing digital content.</p><h3>Try a Simple Online QR Scanner</h3><p>For a quick and reliable browser-based option, you can try <a href="https://qrpeek.me/"><strong>QRPeek.me</strong></a><strong>. </strong>It works on any device — desktop, tablet, or mobile — and lets you:</p><ul><li>Upload images of QR Codes or scan directly with your camera.</li><li>View QR Code content instantly, including URLs, text, or phone numbers.</li><li>Avoid installing extra apps or signing up for accounts.</li></ul><p>It’s simple, fast, and safe — perfect for everyday QR Code scanning needs.</p><h3>Frequently Asked Questions</h3><p><strong>Q: Can I scan QR Codes from PDFs?</strong><br> A: Yes! Save the QR Code as an image, then upload it to a web-based scanner like QRPeek.me.</p><p><strong>Q: Is online QR scanning safe?</strong><br> A: Stick to reputable sites. Avoid scanners that require downloads or unnecessary permissions.</p><p><strong>Q: Can I scan multiple QR Codes at once?</strong><br> A: Yes! Browser-based scanners make it faster to process several images or screenshots in one session.</p><h3>Conclusion</h3><p>QR Codes are convenient, but scanning them isn’t always straightforward. Understanding the differences between mobile and desktop scanning, common challenges, and practical tips can save you time and frustration.</p><p>If you want a <strong>fast, reliable, and browser-based QR scanner</strong>, try <a href="https://qrpeek.me/"><strong>QRPeek.me</strong></a><strong>. </strong>It lets you scan QR Codes online instantly and works across devices — no downloads or registration required.</p><p>With the right approach, scanning QR Codes becomes simple, whether you’re at home, at work, or on the go.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e534b7f82a12" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>