<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Scott</title>
    <description>The latest articles on DEV Community by Scott (@datplan).</description>
    <link>https://dev.to/datplan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4054024%2Fd6c71026-608a-485b-88d3-c3bc98200766.png</url>
      <title>DEV Community: Scott</title>
      <link>https://dev.to/datplan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/datplan"/>
    <language>en</language>
    <item>
      <title>Why a £24,000 HubSpot pipeline shows £44,000 in Power BI</title>
      <dc:creator>Scott</dc:creator>
      <pubDate>Tue, 17 Nov 2026 23:56:49 +0000</pubDate>
      <link>https://dev.to/datplan_datapull/why-a-ps24000-hubspot-pipeline-shows-ps44000-in-power-bi-28gf</link>
      <guid>https://dev.to/datplan_datapull/why-a-ps24000-hubspot-pipeline-shows-ps44000-in-power-bi-28gf</guid>
      <description>&lt;p&gt;The sales team added two calls and a meeting to a deal. The forecast went up even though nobody changed the amount. If you export HubSpot data into Power BI, you can reproduce that symptom with three deals and four activity records.&lt;/p&gt;

&lt;p&gt;Here is a small test you can run in a fresh SQLite session. The data is invented, the deals are open and all three amounts use one currency.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="nf"&gt;deals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deal_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'A'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'B'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'C'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nf"&gt;activities&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;activity_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;deal_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'A'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'A'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'A'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'B'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;joined&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deal_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;activity_id&lt;/span&gt;
  &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;deals&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;
  &lt;span class="k"&gt;LEFT&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;activities&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deal_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deal_id&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="nb"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;deals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;correct_pipeline&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;sum_after_join&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;DISTINCT&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;sum_of_distinct_amounts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;COUNT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;DISTINCT&lt;/span&gt; &lt;span class="n"&gt;deal_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;number_of_deals&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;COUNT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;activity_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;number_of_activities&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;joined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pipeline from deals&lt;/th&gt;
&lt;th&gt;Sum after join&lt;/th&gt;
&lt;th&gt;Sum of distinct amounts&lt;/th&gt;
&lt;th&gt;Deals&lt;/th&gt;
&lt;th&gt;Activities&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;£24,000&lt;/td&gt;
&lt;td&gt;£44,000&lt;/td&gt;
&lt;td&gt;£14,000&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Deal A contributes £30,000 after the join because it appears on three rows. Deal B legitimately has the same £10,000 amount. Deduplicating amounts throws B away. Deal C has no activity. Changing the join to an inner join would also drop its £4,000.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keep the amount on the row it describes
&lt;/h3&gt;

&lt;p&gt;In Power BI, put the deal amount on a table with one row per deal. Count activities on a separate table with one row per activity. When filtering by owner or company, check that the keys and relationships give each measure the scope you intend. A total can look plausible even when the relationship is wrong. In this example the distinct count of deals still says three beside the incorrect £44,000.&lt;/p&gt;

&lt;p&gt;If a particular visual needs one row per deal with its number of touches, aggregate the activity rows before joining. To try this with the same data, keep the first two &lt;code&gt;WITH&lt;/code&gt; definitions above, remove the comma after the closing parenthesis of &lt;code&gt;activities&lt;/code&gt;, and replace the rest with this query.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
  &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deal_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nb"&gt;COALESCE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;touch_count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;touch_count&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;deals&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;
&lt;span class="k"&gt;LEFT&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;deal_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;COUNT&lt;/span&gt;&lt;span class="cm"&gt;(*) AS touch_count
  FROM activities
  GROUP BY deal_id
) AS a ON a.deal_id = d.deal_id;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should get A with £10,000 and three touches, B with £10,000 and one touch, and C with £4,000 and zero touches. The amounts sum to £24,000. This example assigns each activity to one deal. If your CRM associates an activity with several deals, retain those associations separately and decide how to count shared touches.&lt;/p&gt;

&lt;p&gt;I would keep these three cases as a refresh test: a deal with several activities, two deals with equal amounts, and a deal with no activity. They catch three different errors that can otherwise look like movements in the forecast.&lt;/p&gt;

&lt;p&gt;I work on Datplan DataPull. Our &lt;a href="https://www.datplan.com/blog/hubspot-power-bi-duplicate-deal-values/?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=nov26_reporting&amp;amp;utm_content=sql_reconciliation" rel="noopener noreferrer"&gt;HubSpot and Power BI reconciliation guide&lt;/a&gt; shows four checks you can use on your own model. Datplan used an AI agent to write this article and execute both SQL examples against the synthetic data.&lt;/p&gt;

</description>
      <category>dataanalytics</category>
      <category>sql</category>
      <category>powerbi</category>
    </item>
    <item>
      <title>Choose the Reporting Grain Before You Choose the Chart</title>
      <dc:creator>Scott</dc:creator>
      <pubDate>Thu, 30 Jul 2026 20:17:28 +0000</pubDate>
      <link>https://dev.to/datplan/choose-the-reporting-grain-before-you-choose-the-chart-cp6</link>
      <guid>https://dev.to/datplan/choose-the-reporting-grain-before-you-choose-the-chart-cp6</guid>
      <description>&lt;p&gt;A chart can be perfectly formatted and still be wrong. In accounting and operational reporting, the most common cause is not the visual—it is the &lt;strong&gt;grain of the data underneath it&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Grain means what one row represents. One row might be an invoice, an invoice line, a payment, an account balance at a reporting date, a CRM deal, or a single activity. Those are different business events.&lt;/p&gt;

&lt;p&gt;When they are treated as interchangeable, totals multiply, dates lose their meaning, and filters answer a different question from the one in the chart title.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with the business question
&lt;/h2&gt;

&lt;p&gt;Before choosing a table or chart, write the question in one sentence:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;How much is outstanding by customer?&lt;/strong&gt; This is an invoice-level question.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Which products generated net sales?&lt;/strong&gt; This is an invoice-line question.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When did cash arrive?&lt;/strong&gt; This is a payment question.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What was the account balance at month end?&lt;/strong&gt; This is a financial-summary question.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The chart type comes later. A bar chart cannot repair a table that mixes recognised revenue, invoice value, and settlement movement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four accounting grains that should stay distinct
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Invoice summary
&lt;/h3&gt;

&lt;p&gt;One row per invoice or bill. Use it for document totals, due dates, paid amounts, balances, and customer or supplier analysis.&lt;/p&gt;

&lt;h3&gt;
  
  
  Invoice lines
&lt;/h3&gt;

&lt;p&gt;One row per product or service line. Use it for item, tracking, quantity, net, tax, and gross analysis.&lt;/p&gt;

&lt;h3&gt;
  
  
  Payments
&lt;/h3&gt;

&lt;p&gt;One row per authorised settlement. Use it for cash timing, receipts, supplier payments, and payment accounts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Financial summary
&lt;/h3&gt;

&lt;p&gt;One row per account and reporting period or date. Use it for profit-and-loss, balance-sheet, and account-movement reporting.&lt;/p&gt;

&lt;p&gt;The same organisation can have valid numbers at every one of these grains. The mistake is expecting them to reconcile by simple addition. An invoice amount is not recognised revenue, a payment is not an invoice total, and an invoice line cannot safely carry the full invoice value on every row.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why totals multiply
&lt;/h2&gt;

&lt;p&gt;Suppose one invoice has five lines and a gross value of £1,000. If the invoice total is joined onto every line and then summed, the result is £5,000.&lt;/p&gt;

&lt;p&gt;Nothing is wrong with the underlying records. The model simply repeated an invoice-level measure at a line-level grain.&lt;/p&gt;

&lt;p&gt;The same effect appears in CRM reporting. One deal joined to eight activities produces eight rows. Summing the deal amount across those rows multiplies pipeline value by eight.&lt;/p&gt;

&lt;p&gt;Distinct counts do not solve every version of this problem. A distinct count can correctly count invoices or deals, but it does not make a repeated amount safe to sum. A distinct sum is also unreliable because two legitimate records can have the same value.&lt;/p&gt;

&lt;h2&gt;
  
  
  A safer star-schema pattern
&lt;/h2&gt;

&lt;p&gt;Keep fact tables at their natural grain. Invoice facts, invoice-line facts, payment facts, and financial-summary facts can share dimensions such as date, contact, account, or tracking category, but they do not need to be flattened into one universal fact table.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use stable business keys and surrogate keys consistently.&lt;/li&gt;
&lt;li&gt;Create role-playing date dimensions when invoice date, due date, and payment date answer different questions.&lt;/li&gt;
&lt;li&gt;Keep measures on the fact table where they are naturally additive.&lt;/li&gt;
&lt;li&gt;Document non-additive balances and snapshot measures.&lt;/li&gt;
&lt;li&gt;Build relationships first, then create measures, then choose visuals.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Refreshes need a stable contract
&lt;/h2&gt;

&lt;p&gt;A good model is not only correct once. It should also be refreshable.&lt;/p&gt;

&lt;p&gt;Stable file names, consistent columns, explicit types, clear endpoint results, and a known reporting grain make the refresh predictable. If a source adds data or an endpoint returns a partial result, the run evidence should make that visible before the dashboard is trusted.&lt;/p&gt;

&lt;p&gt;This is why the data-preparation layer matters. It separates source retrieval from the reporting model and gives the analyst a place to validate row counts, dates, totals, and relationships.&lt;/p&gt;

&lt;h2&gt;
  
  
  A practical pre-chart checklist
&lt;/h2&gt;

&lt;p&gt;Before building a visual, ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What does one row represent?&lt;/li&gt;
&lt;li&gt;Which date gives the measure its business meaning?&lt;/li&gt;
&lt;li&gt;Is the measure additive across rows, time, and categories?&lt;/li&gt;
&lt;li&gt;Can a join repeat the measure?&lt;/li&gt;
&lt;li&gt;Which table owns the measure?&lt;/li&gt;
&lt;li&gt;What run evidence confirms that the refresh completed as expected?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where Datplan DataPull fits
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.datplan.com/" rel="noopener noreferrer"&gt;Datplan DataPull&lt;/a&gt; uses separate documented reporting grains for authorised business data and prepares local fact-and-dimension exports for BI tools.&lt;/p&gt;

&lt;p&gt;The product does not remove the need to understand the model. It makes the grain and refresh boundary easier to inspect before a polished chart repeats the wrong value.&lt;/p&gt;

&lt;p&gt;For a practical Xero example, see &lt;a href="https://www.datplan.com/blog/xero-star-schema-power-bi/" rel="noopener noreferrer"&gt;How to prepare a Xero star schema for Power BI&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>accounting</category>
      <category>dataengineering</category>
      <category>businessintelligence</category>
      <category>sql</category>
    </item>
  </channel>
</rss>
