<?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: Need help in writing DAX query formula in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-writing-DAX-query-formula/m-p/4005537#M156469</link>
    <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Create a Calculated Table&lt;/STRONG&gt;: First, create a calculated table that lists all the unique combinations of product codes and territories.&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ProductTerritoryCombination = 
CROSSJOIN (
    DISTINCT ( SalesData[ProductCode] ),
    DISTINCT ( SalesData[Territory] )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Count Total Product-Territory Combinations&lt;/STRONG&gt;: Create a measure to count the total number of product-territory combinations.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TotalProductTerritoryCombinations = 
COUNTROWS ( ProductTerritoryCombination )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Count Actual Sales Combinations&lt;/STRONG&gt;: Create a measure to count the actual number of product-territory combinations that have sales.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ActualProductTerritoryCombinations = 
COUNTROWS ( 
    SUMMARIZE (
        SalesData,
        SalesData[ProductCode],
        SalesData[Territory]
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Calculate the Difference&lt;/STRONG&gt;: Create a measure to calculate the difference between the total possible combinations and the actual sales combinations.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;MissingProductTerritoryCombinations = 
[TotalProductTerritoryCombinations] - [ActualProductTerritoryCombinations]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Calculate the Percentage&lt;/STRONG&gt;: Finally, create a measure to calculate the percentage of product codes that are not sold in all territories.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PercentageMissingProductTerritoryCombinations = 
DIVIDE (
    [MissingProductTerritoryCombinations],
    [TotalProductTerritoryCombinations]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 23 Jun 2024 12:09:09 GMT</pubDate>
    <dc:creator>aduguid</dc:creator>
    <dc:date>2024-06-23T12:09:09Z</dc:date>
    <item>
      <title>Need help in writing DAX query formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-writing-DAX-query-formula/m-p/4005529#M156468</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to write a Dax query for the below on e but the expected results are not coming. Could you guys help me in this.&lt;BR /&gt;&lt;BR /&gt;I have sales data which contains the product codes, territory, state, city and sales amount. most product codes are sold in all territories but there are some product codes which are not sold in all territories.&amp;nbsp; I need to create a measure to calculate the percentage of productcodes which are not sold everywhere in territories.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Attaching the sample&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2024 11:55:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-writing-DAX-query-formula/m-p/4005529#M156468</guid>
      <dc:creator>AshwiniPulipat</dc:creator>
      <dc:date>2024-06-23T11:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in writing DAX query formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-writing-DAX-query-formula/m-p/4005537#M156469</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Create a Calculated Table&lt;/STRONG&gt;: First, create a calculated table that lists all the unique combinations of product codes and territories.&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ProductTerritoryCombination = 
CROSSJOIN (
    DISTINCT ( SalesData[ProductCode] ),
    DISTINCT ( SalesData[Territory] )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Count Total Product-Territory Combinations&lt;/STRONG&gt;: Create a measure to count the total number of product-territory combinations.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TotalProductTerritoryCombinations = 
COUNTROWS ( ProductTerritoryCombination )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Count Actual Sales Combinations&lt;/STRONG&gt;: Create a measure to count the actual number of product-territory combinations that have sales.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ActualProductTerritoryCombinations = 
COUNTROWS ( 
    SUMMARIZE (
        SalesData,
        SalesData[ProductCode],
        SalesData[Territory]
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Calculate the Difference&lt;/STRONG&gt;: Create a measure to calculate the difference between the total possible combinations and the actual sales combinations.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;MissingProductTerritoryCombinations = 
[TotalProductTerritoryCombinations] - [ActualProductTerritoryCombinations]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Calculate the Percentage&lt;/STRONG&gt;: Finally, create a measure to calculate the percentage of product codes that are not sold in all territories.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PercentageMissingProductTerritoryCombinations = 
DIVIDE (
    [MissingProductTerritoryCombinations],
    [TotalProductTerritoryCombinations]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2024 12:09:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-writing-DAX-query-formula/m-p/4005537#M156469</guid>
      <dc:creator>aduguid</dc:creator>
      <dc:date>2024-06-23T12:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in writing DAX query formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-writing-DAX-query-formula/m-p/4005546#M156470</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;% of product count not-all-territory: =
VAR _result =
    COUNTROWS (
        FILTER (
            VALUES ( 'product'[product_code] ),
            CALCULATE ( COUNTROWS ( SUMMARIZE ( data, territory[territory] ) ) ) &amp;lt;&amp;gt; 4
        )
    )
VAR _allproduct =
    COUNTROWS ( VALUES ( 'product'[product_code] ) )
RETURN
    DIVIDE ( _result, _allproduct )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2024 12:18:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-writing-DAX-query-formula/m-p/4005546#M156470</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-06-23T12:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in writing DAX query formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-writing-DAX-query-formula/m-p/4008599#M157381</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="763767" data-lia-user-login="AshwiniPulipat" class="lia-mention lia-mention-user"&gt;AshwiniPulipat&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;SPAN&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="81736" data-lia-user-login="aduguid" class="lia-mention lia-mention-user"&gt;aduguid&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;very much for the solution, and&amp;nbsp;I've tried other ways to help you understand the problem:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;PercentageNotsoldEverywhere = 
VAR _count1 =
    CALCULATE (
        DISTINCTCOUNT ( 'Table (2)'[Territory] ),
         ALLSELECTED ( 'Table (2)' )
    )
VAR _count2 =
    CALCULATE (
        DISTINCTCOUNT ( 'Table (2)'[Territory] ),
        ALLEXCEPT ( 'Table (2)', 'Table (2)'[Prouduct code] )
    )
RETURN
1 - DIVIDE ( _count2, _count1 )
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;You change to the new data source you need to use in the following actions.&lt;/P&gt;
&lt;P&gt;Hope it helps!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Community Support Team_ Tom Shen&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 07:55:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-writing-DAX-query-formula/m-p/4008599#M157381</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-25T07:55:01Z</dc:date>
    </item>
  </channel>
</rss>

