<?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 Measure excluding row context in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4284622#M170052</link>
    <description>&lt;P&gt;I have tables:&lt;/P&gt;&lt;P&gt;- dimension table dim_Model with columns Model UID, Model Name, Factory (each Model UID has 1 unique Model Name and vice versa)&lt;/P&gt;&lt;P&gt;- dimension table dim_Style with columns Style UID, Style Name&lt;/P&gt;&lt;P&gt;- fact table fact_Accessory with columns Model UID, Style UID,&amp;nbsp;Accessory_UID, Is_Metallic, Year, Price&lt;/P&gt;&lt;P&gt;I want to create a visual table of columns Model Name, Factory, Style Name, Nr Metallic Accessories &lt;EM&gt;which is Distinct Count of Accessory_UID with Is_Metallic=1 for Model Name. &lt;/EM&gt;I expect that&amp;nbsp;Nr Metallic Accessories is the same for each Model Name regardless Style Name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried these queries but they don't work:&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;LI-CODE lang="markup"&gt;nr_Metallic_Accesories_1 = CALCULATE(
    SUMX(
        SUMMARIZE('fact_Accessory','fact_Accessory'[Accessory UID],'fact_Accessory'[Is_Metallic])
        ,[Is_Metallic]
    )
    ,REMOVEFILTERS('dim_Style')
    ,FILTER(
        'fact_Accessory'
        ,'fact_Accessory'[Is_Metallic]=1
    )
)

nr_Metallic_Accessories_2 = 
var _model_uid = SELECTEDVALUE('dim_Model'[Model UID])
return
CALCULATE(
	DISTINCTCOUNT('fact_Accessory'[Accessory UID]),
    FILTER( 
        ALLSELECTED('fact_Accessory')
        ,'fact_Accessory'[Model UID] = _model_uid
        &amp;amp;&amp;amp; 'fact_Accessory'[Is_Metallic]=1
    ) 
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone help me with this, please? Thank you.&lt;/P&gt;</description>
    <pubDate>Thu, 14 Nov 2024 20:16:53 GMT</pubDate>
    <dc:creator>liselotte</dc:creator>
    <dc:date>2024-11-14T20:16:53Z</dc:date>
    <item>
      <title>Measure excluding row context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4284622#M170052</link>
      <description>&lt;P&gt;I have tables:&lt;/P&gt;&lt;P&gt;- dimension table dim_Model with columns Model UID, Model Name, Factory (each Model UID has 1 unique Model Name and vice versa)&lt;/P&gt;&lt;P&gt;- dimension table dim_Style with columns Style UID, Style Name&lt;/P&gt;&lt;P&gt;- fact table fact_Accessory with columns Model UID, Style UID,&amp;nbsp;Accessory_UID, Is_Metallic, Year, Price&lt;/P&gt;&lt;P&gt;I want to create a visual table of columns Model Name, Factory, Style Name, Nr Metallic Accessories &lt;EM&gt;which is Distinct Count of Accessory_UID with Is_Metallic=1 for Model Name. &lt;/EM&gt;I expect that&amp;nbsp;Nr Metallic Accessories is the same for each Model Name regardless Style Name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried these queries but they don't work:&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;LI-CODE lang="markup"&gt;nr_Metallic_Accesories_1 = CALCULATE(
    SUMX(
        SUMMARIZE('fact_Accessory','fact_Accessory'[Accessory UID],'fact_Accessory'[Is_Metallic])
        ,[Is_Metallic]
    )
    ,REMOVEFILTERS('dim_Style')
    ,FILTER(
        'fact_Accessory'
        ,'fact_Accessory'[Is_Metallic]=1
    )
)

nr_Metallic_Accessories_2 = 
var _model_uid = SELECTEDVALUE('dim_Model'[Model UID])
return
CALCULATE(
	DISTINCTCOUNT('fact_Accessory'[Accessory UID]),
    FILTER( 
        ALLSELECTED('fact_Accessory')
        ,'fact_Accessory'[Model UID] = _model_uid
        &amp;amp;&amp;amp; 'fact_Accessory'[Is_Metallic]=1
    ) 
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone help me with this, please? Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2024 20:16:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4284622#M170052</guid>
      <dc:creator>liselotte</dc:creator>
      <dc:date>2024-11-14T20:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: Measure excluding row context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4284772#M170060</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="688542" data-lia-user-login="liselotte" class="lia-mention lia-mention-user"&gt;liselotte&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you supply sample data please, or your PBIX file.&amp;nbsp; You'll get help quicker if we don't have to recreate the data for all the tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Phil&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2024 23:06:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4284772#M170060</guid>
      <dc:creator>PhilipTreacy</dc:creator>
      <dc:date>2024-11-14T23:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Measure excluding row context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4285198#M170089</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="688542" data-lia-user-login="liselotte" class="lia-mention lia-mention-user"&gt;liselotte&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To create a table showing Model Name, Factory, Style Name, and Nr Metallic Accessories with a consistent count of metallic accessories for each Model Name regardless of Style Name, you’ll want to do the following in DAX:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Calculate the Distinct Count of Metallic Accessories&lt;/STRONG&gt; for each Model Name with Is_Metallic = 1.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Remove Filters on Style Name&lt;/STRONG&gt; so that Nr Metallic Accessories is not affected by the Style dimension.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Here’s a measure that should achieve this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Nr_Metallic_Accessories = 
CALCULATE(
    DISTINCTCOUNT('fact_Accessory'[Accessory UID]),
    'fact_Accessory'[Is_Metallic] = 1,
    REMOVEFILTERS('dim_Style'[Style UID]) // Removes the Style filter to avoid interference
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a visual table with:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Model Name, Factory, and Style Name from your dimension tables.&lt;/LI&gt;&lt;LI&gt;Nr Metallic Accessories from the measure we just defined.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This measure should produce the same count of metallic accessories for each Model Name across all styles. Let me know if this approach works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution, this will help others!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If my response(s) assisted you in any way, don't forget to drop me a "&lt;STRONG&gt;Kudos&lt;/STRONG&gt;" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;BR /&gt;Poojara&lt;BR /&gt;Data Analyst | MSBI Developer | Power BI Consultant&lt;BR /&gt;&lt;STRONG&gt;YouTube&lt;/STRONG&gt;: &lt;A href="https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS" target="_blank" rel="noopener"&gt;https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 05:02:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4285198#M170089</guid>
      <dc:creator>Poojara_D12</dc:creator>
      <dc:date>2024-11-15T05:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: Measure excluding row context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4285397#M170100</link>
      <description>&lt;P&gt;Thanks for the replies from&amp;nbsp;Poojara_D12&amp;nbsp;and&amp;nbsp;PhilipTreacy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="688542" data-lia-user-login="liselotte" class="lia-mention lia-mention-user"&gt;liselotte&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With a modification on the formula you gave, please try:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;nr_Metallic_Accessories_2 =
VAR _model_uid =
    SELECTEDVALUE ( 'dim_Model'[Model UID] )
RETURN
    IF (
        MAX ( 'fact_Accessory'[Is_Metallic] ) = 1,
        CALCULATE (
            DISTINCTCOUNT ( 'fact_Accessory'[Accessory_UID] ),
            FILTER (
                ALLSELECTED ( 'fact_Accessory' ),
                'fact_Accessory'[Model UID] = _model_uid
                    &amp;amp;&amp;amp; 'fact_Accessory'[Is_Metallic] = 1
            )
        )
    )&lt;/LI-CODE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Zhu&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;I&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/I&gt;, then please consider&amp;nbsp;&lt;I&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/I&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 06:44:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4285397#M170100</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-15T06:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: Measure excluding row context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4295876#M170518</link>
      <description>&lt;P&gt;Hi Zhu,&lt;/P&gt;&lt;P&gt;Thank you for your help and sorry for my late response. Your suggested query seems to work well for the rows with Sum of Is_Metallic =1, but I expected that the second row in your screenshot should have nr_Metallic_Accessories_2=2 too. Is there any way to do that? Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2024 19:18:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4295876#M170518</guid>
      <dc:creator>liselotte</dc:creator>
      <dc:date>2024-11-21T19:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: Measure excluding row context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4299235#M170722</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="688542" data-lia-user-login="liselotte" class="lia-mention lia-mention-user"&gt;liselotte&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try this formula:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;nr_Metallic_Accessories_2 = 
IF(MAX('fact_Accessory'[Is_Metallic]) in {0,1},
CALCULATE(
	SUM('fact_Accessory'[Is_Metallic]),
	ALLEXCEPT('fact_Accessory','fact_Accessory'[Model UID])
))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Zhu&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;I&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/I&gt;, then please consider&amp;nbsp;&lt;I&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/I&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 06:37:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4299235#M170722</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-25T06:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: Measure excluding row context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4299482#M170733</link>
      <description>&lt;P&gt;That works like a charm. Thank you very much! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 08:22:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-excluding-row-context/m-p/4299482#M170733</guid>
      <dc:creator>liselotte</dc:creator>
      <dc:date>2024-11-25T08:22:36Z</dc:date>
    </item>
  </channel>
</rss>

