<?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 Re: DAX code for comparing two tables, and showing the differences - Is it efficient enough? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481832#M133136</link>
    <description>&lt;P&gt;How do i remove recent datasources from a PBIX file before sharing?&amp;nbsp;&lt;BR /&gt;I am afraid of sharing recent datasources and credentials&lt;/P&gt;</description>
    <pubDate>Tue, 17 Oct 2023 19:33:39 GMT</pubDate>
    <dc:creator>MegaOctane1</dc:creator>
    <dc:date>2023-10-17T19:33:39Z</dc:date>
    <item>
      <title>DAX code for comparing two tables, and showing the differences - Is it efficient enough?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481394#M133105</link>
      <description>&lt;P&gt;Hello guys,&lt;/P&gt;&lt;P&gt;I have two tables, with the columns:&amp;nbsp;&lt;BR /&gt;CustomerNumber, InvoiceNumber, Amount, Key (the key column is "invoicenumber &amp;amp; amount")&lt;BR /&gt;I compare these, and with DAX formula, i get a new table with the differences.&amp;nbsp;&lt;BR /&gt;Can somebody check if the code is "efficient"?&lt;/P&gt;&lt;P&gt;I cannot to it in Power Query because one of the tables are a api query which uses 30-50 minutes to run, and it can time out i was told. Either way, the code below works fast.&amp;nbsp;&lt;BR /&gt;not sure if it is efficient enough.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="ruby"&gt;SAP_InvoicePartner_DIFFERENCES = 
VAR SAP=
    CALCULATETABLE(
        EXCEPT(
            VALUES('SAP Invoices'[SAPKEY]),
            VALUES('Partner Invoices'[KREDKEY])
            ),
            INTERSECT(VALUES('SAP Invoices'[CustomerNumber]),VALUES('Partner Invoices'[CustomerNumber]))
    )

VAR InvoicePartner=
    CALCULATETABLE(
        EXCEPT(
            VALUES('Partner Invoices'[KREDKEY]),
            VALUES('SAP Invoices'[SAPKEY])
            ),
            INTERSECT(VALUES('SAP Invoices'[CustomerNumber]),VALUES('Partner Invoices'[CustomerNumber]))
    )
RETURN
UNION (
GENERATE(
    SAP,
    CALCULATETABLE(
        SELECTCOLUMNS(
            'SAP Invoices',
            "CustomerNumber",[CustomerNumber],
            "InvoiceNumber",[InvoiceNumber],
            "Amount",[InvoiceAmount],
            "Kilde","SAP"
            )
        )
    ),

GENERATE(
    InvoicePartner,
    CALCULATETABLE(
        SELECTCOLUMNS(
            'Partner Invoices',
            "CustomerNumber",[CustomerNumber],
            "InvoiceNumber",[InvoiceNumber],
            "Amount",([InvoiceAmount]),
            "Kilde","InvoicePartner"
            )
        )
    )
)
    &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 14:58:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481394#M133105</guid>
      <dc:creator>MegaOctane1</dc:creator>
      <dc:date>2023-10-17T14:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: DAX code for comparing two tables, and showing the differences - Is it efficient enough?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481432#M133109</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="594990" data-lia-user-login="MegaOctane1" class="lia-mention lia-mention-user"&gt;MegaOctane1&lt;/a&gt;&amp;nbsp;Here are some suggested changes, not sure if will improve performance greatly. Any chance you can post sample data?&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SAP_InvoicePartner_DIFFERENCES = 
VAR SAP=
    CALCULATETABLE(
        EXCEPT(
            DISTINCT('SAP Invoices'[SAPKEY]),
            DISTINCT('Partner Invoices'[KREDKEY])
            ),
            INTERSECT(DISTINCT('SAP Invoices'[CustomerNumber]),DISTINCT('Partner Invoices'[CustomerNumber]))
    )

VAR InvoicePartner=
    CALCULATETABLE(
        EXCEPT(
            DISTINCT('Partner Invoices'[KREDKEY]),
            DISTINCT('SAP Invoices'[SAPKEY])
            ),
            INTERSECT(DISTINCT('SAP Invoices'[CustomerNumber]),DISTINCT('Partner Invoices'[CustomerNumber]))
    )
RETURN

UNION (
GENERATE(
    SAP,
    SELECTCOLUMNS(
        'SAP Invoices',
        "CustomerNumber",[CustomerNumber],
        "InvoiceNumber",[InvoiceNumber],
        "Amount",[InvoiceAmount],
        "Kilde","SAP"
        )
    ),

GENERATE(
    InvoicePartner,
    SELECTCOLUMNS(
        'Partner Invoices',
        "CustomerNumber",[CustomerNumber],
        "InvoiceNumber",[InvoiceNumber],
        "Amount",([InvoiceAmount]),
        "Kilde","InvoicePartner"
        )
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 15:18:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481432#M133109</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-10-17T15:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: DAX code for comparing two tables, and showing the differences - Is it efficient enough?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481446#M133110</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;I will try to upload a pbix file later today. Just have to clean it up a little bit.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 15:26:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481446#M133110</guid>
      <dc:creator>MegaOctane1</dc:creator>
      <dc:date>2023-10-17T15:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: DAX code for comparing two tables, and showing the differences - Is it efficient enough?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481832#M133136</link>
      <description>&lt;P&gt;How do i remove recent datasources from a PBIX file before sharing?&amp;nbsp;&lt;BR /&gt;I am afraid of sharing recent datasources and credentials&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 19:33:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481832#M133136</guid>
      <dc:creator>MegaOctane1</dc:creator>
      <dc:date>2023-10-17T19:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: DAX code for comparing two tables, and showing the differences - Is it efficient enough?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481855#M133137</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="594990" data-lia-user-login="MegaOctane1" class="lia-mention lia-mention-user"&gt;MegaOctane1&lt;/a&gt;&amp;nbsp;Those are not part of the PBIX file. Those items are cached locally on your computer. I run Power BI Desktop on multiple systems. My recent data sources are not the same between them and if I open a PBIX file on another computer, I have to re-establish the credentials.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 19:50:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481855#M133137</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-10-17T19:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: DAX code for comparing two tables, and showing the differences - Is it efficient enough?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481880#M133138</link>
      <description>&lt;P&gt;&lt;A title="PBIX tile with sample data" href="https://drive.google.com/file/d/1Sfib5_wCaoIK2Mxad_Hcdq0A91REiM_R/view?usp=sharing" target="_self"&gt;PBIX tile with sample data&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;Let me know if it works. and if the data is clean &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;I would also like your help to create a mesure to count how many customers has difference in the balance. I have only one customer with zero difference. so the answer should be 4...&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 20:08:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481880#M133138</guid>
      <dc:creator>MegaOctane1</dc:creator>
      <dc:date>2023-10-17T20:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: DAX code for comparing two tables, and showing the differences - Is it efficient enough?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481912#M133139</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="594990" data-lia-user-login="MegaOctane1" class="lia-mention lia-mention-user"&gt;MegaOctane1&lt;/a&gt;&amp;nbsp;Big help. So, why can't you just do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SAP_InvoicePartner_DIFFERENCES 3 = 
    VAR __SAP = SELECTCOLUMNS('SAP Invoices', "CustomerNumber", [CustomerNumber], "InvoiceNumber", [InvoiceNumber], "Amount", [Amount])
    VAR __InvoicePartner = SELECTCOLUMNS('Partner Invoices', "CustomerNumber", [CustomerNumber], "InvoiceNumber", [InvoiceNumber], "Amount", [Amount])
    VAR __SAPExcept = EXCEPT(__SAP, __InvoicePartner)
    VAR __PartnerExcept = EXCEPT( __InvoicePartner, __SAP)
    VAR __Result = 
        UNION(
            ADDCOLUMNS( __SAPExcept, "Kilde", "SAP"),
            ADDCOLUMNS( __PartnerExcept, "Kilde", "InvoicePartner")
        )
RETURN
    __Result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 20:38:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3481912#M133139</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-10-17T20:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: DAX code for comparing two tables, and showing the differences - Is it efficient enough?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3482406#M133187</link>
      <description>&lt;P&gt;Nice, simple, neat - Perfect!!&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;One more question: How do i count how many customers doesn't have 0 balance when compared? So i can have this value in a card visual.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 05:35:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3482406#M133187</guid>
      <dc:creator>MegaOctane1</dc:creator>
      <dc:date>2023-10-18T05:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: DAX code for comparing two tables, and showing the differences - Is it efficient enough?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3483394#M133236</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="594990" data-lia-user-login="MegaOctane1" class="lia-mention lia-mention-user"&gt;MegaOctane1&lt;/a&gt;&amp;nbsp;Well, you could do something like this (accounting for floating point inaccuracies):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count Non-Zero Balances = 
    VAR __Table = SUMMARIZE('CustomerMaster', [Name], "__Value", SUM('SAP Invoices'[Amount]) - SUM('Partner Invoices'[Amount]))
    VAR __Result = COUNTROWS(FILTER(__Table, [__Value] &amp;gt; .0001 || [__Value] &amp;lt; -.0001))
RETURN
    __Result&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 18 Oct 2023 13:16:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3483394#M133236</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-10-18T13:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: DAX code for comparing two tables, and showing the differences - Is it efficient enough?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3485114#M133344</link>
      <description>&lt;P&gt;It works!! Thanks&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 08:50:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-for-comparing-two-tables-and-showing-the-differences-Is/m-p/3485114#M133344</guid>
      <dc:creator>MegaOctane1</dc:creator>
      <dc:date>2023-10-19T08:50:48Z</dc:date>
    </item>
  </channel>
</rss>

