<?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: Filter Fact Table on inactive relationship and then calculate measure in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4207768#M166820</link>
    <description>&lt;P&gt;Thank you for your suggestion. I have tried the solution and it works and I get the result I expected!&lt;/P&gt;&lt;P&gt;I am just wondering, for my understanding, is this solution best practice in terms of performance, or should I have changed my data model to make the calculation via USERALATIONSHIP work?&lt;/P&gt;</description>
    <pubDate>Tue, 01 Oct 2024 11:34:05 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-10-01T11:34:05Z</dc:date>
    <item>
      <title>Filter Fact Table on inactive relationship and then calculate measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4201637#M166694</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am somehow stuck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dimension table (let's call it DCC) with cost centres [Cost Center ID], [Cost Center Name]. I also have a fact table (let's call it FP) with [Cost Centre ID Project], [Cost Centre ID Employee], [Project Hours].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two tables are linked by an active relationship between DCC[Cost Centre ID] and FP[Cost Centre ID Project]. The inactive relationship exists between DCC[Cost Centre ID] and FP[Cost Centre ID Employee]. I would like to calculate how many hours per project have been incurred in a cost centre BU IT (i.e. active connection), but at the same time employees from a cost centre BU GR (i.e. inactive connection) must not be counted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried this formula:&lt;BR /&gt;Project Hours without BU GR =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;[Project Hours],&lt;BR /&gt;FILTER (&lt;BR /&gt;ALL ( DCC[Cost Centre Name] ),&lt;BR /&gt;NOT ( DCC[Cost Centre Name] ) IN { "BU GR" }&lt;BR /&gt;),&lt;BR /&gt;USERELATIONSHIP ( DCC[Cost Centre ID], FP[Cost Centre ID Employee] )&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;Unfortunately, the employees from Cost Centre BU GR are filtered out, but at the same time the filter context for [Cost Centre ID Project] (namely Cost Centre BU IT) is ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have an idea how to implement this?&amp;nbsp; I need to filter the fact table via the inactive relationship first and then do the calculation with all filter contexts.&lt;BR /&gt;&lt;BR /&gt;Thanks for support.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2024 15:43:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4201637#M166694</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-30T15:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Fact Table on inactive relationship and then calculate measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4202608#M166725</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may need to do the calculation in 2 parts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR _ExcludeEmployees =&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;CALCULATETABLE (&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;DISTINCT(DCC[Cost Centre ID]),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;REMOVEFILTERS(&lt;SPAN&gt;DCC),&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;DCC[Cost Centre Name] = "BU GR"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;VAR _Result =&amp;nbsp;&lt;/P&gt;&lt;P&gt;CALCULATE(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; [Project Hours],&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;NOT FP[Cost Centre ID Employee] IN ( _ExcludeEmployees )&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; _Result&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2024 19:56:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4202608#M166725</guid>
      <dc:creator>PaulOlding</dc:creator>
      <dc:date>2024-09-30T19:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Fact Table on inactive relationship and then calculate measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4205035#M166766</link>
      <description>&lt;P&gt;see if this code works for you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Project Hours without BU GR =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;[Project Hours],&lt;BR /&gt;// Step 1: Activate the inactive relationship for filtering Cost Centre ID Employee&lt;BR /&gt;USERELATIONSHIP ( DCC[Cost Centre ID], FP[Cost Centre ID Employee] ),&lt;BR /&gt;&lt;BR /&gt;// Step 2: Ensure the Cost Centre ID Project context remains intact&lt;BR /&gt;KEEPFILTERS ( DCC[Cost Centre Name] = "BU IT" ),&lt;/P&gt;&lt;P&gt;// Step 3: Exclude rows where employees belong to BU GR&lt;BR /&gt;FILTER (&lt;BR /&gt;ALL ( DCC[Cost Centre Name] ),&lt;BR /&gt;NOT ( DCC[Cost Centre Name] = "BU GR" )&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 04:27:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4205035#M166766</guid>
      <dc:creator>siddharth1k</dc:creator>
      <dc:date>2024-10-01T04:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Fact Table on inactive relationship and then calculate measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4206372#M166803</link>
      <description>&lt;P&gt;Thank you for your suggestion.&lt;BR /&gt;But as I understand, as long as the USERALATIONSHIP is active within the CALCULATION, the KEEPFILTRES will also use the inactive aka [Cost Center ID Employee] relationship, but for the filtering of BU IT it should be the active aka [Cost Center ID Project] relationship. Also, the filtering part of BU IT should not be coded "hardcopy" in the measure.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 08:38:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4206372#M166803</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-01T08:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Fact Table on inactive relationship and then calculate measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4207768#M166820</link>
      <description>&lt;P&gt;Thank you for your suggestion. I have tried the solution and it works and I get the result I expected!&lt;/P&gt;&lt;P&gt;I am just wondering, for my understanding, is this solution best practice in terms of performance, or should I have changed my data model to make the calculation via USERALATIONSHIP work?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 11:34:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4207768#M166820</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-01T11:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Fact Table on inactive relationship and then calculate measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4208552#M166853</link>
      <description>&lt;P&gt;That's an interesting question.&amp;nbsp; I don't think I'll be able to give a definitive answer so if anyone else has opinions on it I'd be interested to read them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My 2 cents: I'd expect a physical relationship to be faster than virtual one&amp;nbsp;&lt;A href="https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/" target="_self"&gt;https://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/&lt;/A&gt;&amp;nbsp;.&amp;nbsp; To use physical relationships for this calculation you'd need 2 DCC tables, both with an active relationship to the fact.&amp;nbsp; Most best practice guides I've read don't recommend having these role-playing dimensions, preferring to have a single copy of the dimension table with multiple relationships to the fact (as you have it now).&amp;nbsp; Personally, I almost always ignore that advice and use role-playing dimensions.&amp;nbsp; This is mostly because I'm creating models for business users to build reports with, and I find it's less intuitive to understand you need to use a different copy of a measure depending on which relationship you want active, and the same column can have a different meaning depending on which measure you use.&amp;nbsp; This certainly leads to models being larger in size though.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess the ultimate best practice is 'try it out with your model and data'.&amp;nbsp; Benchmarking the options with your exact situation is going to give you the best information on performance to make a decision.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 13:14:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4208552#M166853</guid>
      <dc:creator>PaulOlding</dc:creator>
      <dc:date>2024-10-01T13:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Fact Table on inactive relationship and then calculate measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4211856#M166990</link>
      <description>&lt;P&gt;Thanks for your 2 cents ;). I will give it a try and try to post the results of the benchmark here.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2024 11:04:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Fact-Table-on-inactive-relationship-and-then-calculate/m-p/4211856#M166990</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-02T11:04:29Z</dc:date>
    </item>
  </channel>
</rss>

