<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Duplicates in fact table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Duplicates-in-fact-table/m-p/2708619#M82209</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;please take a look into following fact table. The data is normally on Customer, Material, InvoiceNo, Date level.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After ETL processes there are SalesReps assigned to each line (basing on Customer, Product combination) which generates&amp;nbsp; duplicates in the fact table.&amp;nbsp;In the real-life case there are some more hierarchy levels regarding SalesReps and therefore there might more than 1 duplicates for each combination - see R1 and R2).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An assumption has been made that for every original line every single SalesRep gets the same Quantity Sold assigned equally for his KPIs. The total flag indicates the unique row to be taken for the purpose of calculations on the level of detail upper than SalesRep and has been assigned in a RANDOM way. It is also important that the data can be filtered by all dimensions in the example as well as by single SalesRep.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My formula looks like this and does not need to use the TotalFlag at all:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR table1 =&lt;BR /&gt;ADDCOLUMNS (&lt;BR /&gt;SUMMARIZE (&lt;BR /&gt;data2,&lt;BR /&gt;data2[Customer],&lt;BR /&gt;data2[Product],&lt;BR /&gt;data2[InvoiceNo],&lt;BR /&gt;data2[Date]&lt;BR /&gt;),&lt;BR /&gt;"selectedvalue quantity", CALCULATE ( SELECTEDVALUE ( data2[QUANTITY SOLD] ) )&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;RETURN&lt;BR /&gt;SUMX ( table1, [selectedvalue quantity] )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which gives following reults:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;but seems to have bad performance on the original dataset (around 100M rows in fact table).&lt;/P&gt;&lt;P&gt;Does anyone have any better solution?&lt;/P&gt;</description>
    <pubDate>Thu, 18 Aug 2022 06:16:55 GMT</pubDate>
    <dc:creator>piotr_pbi</dc:creator>
    <dc:date>2022-08-18T06:16:55Z</dc:date>
    <item>
      <title>Duplicates in fact table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Duplicates-in-fact-table/m-p/2708619#M82209</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;please take a look into following fact table. The data is normally on Customer, Material, InvoiceNo, Date level.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After ETL processes there are SalesReps assigned to each line (basing on Customer, Product combination) which generates&amp;nbsp; duplicates in the fact table.&amp;nbsp;In the real-life case there are some more hierarchy levels regarding SalesReps and therefore there might more than 1 duplicates for each combination - see R1 and R2).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An assumption has been made that for every original line every single SalesRep gets the same Quantity Sold assigned equally for his KPIs. The total flag indicates the unique row to be taken for the purpose of calculations on the level of detail upper than SalesRep and has been assigned in a RANDOM way. It is also important that the data can be filtered by all dimensions in the example as well as by single SalesRep.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My formula looks like this and does not need to use the TotalFlag at all:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR table1 =&lt;BR /&gt;ADDCOLUMNS (&lt;BR /&gt;SUMMARIZE (&lt;BR /&gt;data2,&lt;BR /&gt;data2[Customer],&lt;BR /&gt;data2[Product],&lt;BR /&gt;data2[InvoiceNo],&lt;BR /&gt;data2[Date]&lt;BR /&gt;),&lt;BR /&gt;"selectedvalue quantity", CALCULATE ( SELECTEDVALUE ( data2[QUANTITY SOLD] ) )&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;RETURN&lt;BR /&gt;SUMX ( table1, [selectedvalue quantity] )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which gives following reults:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;but seems to have bad performance on the original dataset (around 100M rows in fact table).&lt;/P&gt;&lt;P&gt;Does anyone have any better solution?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 06:16:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Duplicates-in-fact-table/m-p/2708619#M82209</guid>
      <dc:creator>piotr_pbi</dc:creator>
      <dc:date>2022-08-18T06:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicates in fact table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Duplicates-in-fact-table/m-p/2708647#M82215</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;As a general rule in this sort of case I would think how to improve the ETL process if that causes this issue. As for a Dax Approach one tip that I have noticed is that MAX often has better results than SELECTEDVALUE in this sort of calculation.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 06:32:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Duplicates-in-fact-table/m-p/2708647#M82215</guid>
      <dc:creator>ValtteriN</dc:creator>
      <dc:date>2022-08-18T06:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicates in fact table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Duplicates-in-fact-table/m-p/2732268#M83691</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="428427" data-lia-user-login="piotr_pbi" class="lia-mention lia-mention-user"&gt;piotr_pbi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Has your problem solved? If solved,&amp;nbsp;please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 10:09:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Duplicates-in-fact-table/m-p/2732268#M83691</guid>
      <dc:creator>v-yadongf-msft</dc:creator>
      <dc:date>2022-08-29T10:09:55Z</dc:date>
    </item>
  </channel>
</rss>

