<?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: Count values from Many to One relationship with a condition in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-values-from-Many-to-One-relationship-with-a-condition/m-p/2565427#M73085</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please try the below. It is for creating a new column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Orange shipments count CC =
COUNTROWS (
    SUMMARIZE (
        FILTER ( RELATEDTABLE ( 'Table1' ), 'Table1'[PRODUCT] = "Orange" ),
        'Table1'[SHIPMENT NUMBER]
    )
)
&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 08 Jun 2022 03:55:48 GMT</pubDate>
    <dc:creator>Jihwan_Kim</dc:creator>
    <dc:date>2022-06-08T03:55:48Z</dc:date>
    <item>
      <title>Count values from Many to One relationship with a condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-values-from-Many-to-One-relationship-with-a-condition/m-p/2564770#M73050</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I am new to Power BI and I have been struggling with letting go from the Excel mentality... I have a &lt;STRONG&gt;Table 1&lt;/STRONG&gt; that looks something like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;SHIPMENT NUMBER&lt;/TD&gt;&lt;TD&gt;PRODUCT&lt;/TD&gt;&lt;TD&gt;COUNTRY CODE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Orange&lt;/TD&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;Orange&lt;/TD&gt;&lt;TD&gt;1567&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Apple&lt;/TD&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;Grapes&lt;/TD&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;Apple&lt;/TD&gt;&lt;TD&gt;8907&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And it is related to another table (&lt;STRONG&gt;Table 2&lt;/STRONG&gt;) by the &lt;STRONG&gt;COUNTRY CODE&lt;/STRONG&gt;, but in this table there is only a row for each code, for example:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;COUNTRY CODE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8907&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1567&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9876&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So they have a &lt;STRONG&gt;Many to One relationship&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I need to create a column in Table 2 (the ONE side of the relationship) that has the COUNT OF DISTINCT Shipments for each of the country codes, but WITH THE CONDITION of only counting the shipments that have Oranges:&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;COUNTRY CODE&lt;/TD&gt;&lt;TD&gt;ORANGE SHIPMENTS&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1567&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't only filter the visuals because I need the total value for each country so I can then validate the number of shipments by an If statement on another column of "If it is higher than 10, then 0.2, if not 0"... and then use the value for more calculations.&lt;/P&gt;&lt;P&gt;I have tried the calculate function in the Table 2 column, but it did not seem to work, it returned no value at all:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Orange Shipments= CALCULATE(
    DISTINCTCOUNT('Table 1'[Shipment Number]),
    'Table 1'[Product]= "Orange")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please, how can I summarize the count of shipments with oranges by country? This has been making me crazy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 18:20:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-values-from-Many-to-One-relationship-with-a-condition/m-p/2564770#M73050</guid>
      <dc:creator>Bia</dc:creator>
      <dc:date>2022-06-07T18:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: Count values from Many to One relationship with a condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-values-from-Many-to-One-relationship-with-a-condition/m-p/2565427#M73085</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please try the below. It is for creating a new column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Orange shipments count CC =
COUNTROWS (
    SUMMARIZE (
        FILTER ( RELATEDTABLE ( 'Table1' ), 'Table1'[PRODUCT] = "Orange" ),
        'Table1'[SHIPMENT NUMBER]
    )
)
&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 08 Jun 2022 03:55:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-values-from-Many-to-One-relationship-with-a-condition/m-p/2565427#M73085</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2022-06-08T03:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Count values from Many to One relationship with a condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-values-from-Many-to-One-relationship-with-a-condition/m-p/2571267#M73444</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="398478" data-lia-user-login="Bia" class="lia-mention lia-mention-user"&gt;Bia&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please check this formula:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column =
CALCULATE (
    DISTINCTCOUNT ( 'Table 1'[SHIPMENT NUMBER] ),
    FILTER (
        'Table 1',
        'Table 1'[COUNTRY CODE] = 'Table 2'[COUNTRY CODE]
            &amp;amp;&amp;amp; 'Table 1'[PRODUCT] = "Orange"
    )
)
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Jay&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2022 08:53:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-values-from-Many-to-One-relationship-with-a-condition/m-p/2571267#M73444</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-10T08:53:27Z</dc:date>
    </item>
  </channel>
</rss>

