<?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: Apply same filter across multiple related tables (power pivot only) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Apply-same-filter-across-multiple-related-tables-power-pivot/m-p/1311537#M22900</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for a very quick response.&lt;/P&gt;&lt;P&gt;Apologies but I am having troubles following your answer.&lt;/P&gt;&lt;P&gt;One of the joint (TabSAPCode to TabSAPLog) is already inactive because precisely the filter on TabStream cannot be followed for both which is precisely what I want to achieve, i.e., I want to have a measure that when a filter is applied on TabStream[Stream] filters both TabSAPCcode and TabResource (which it does) but that then this filtering is propagated down to TabSAPLog and that the only records in TabSAPLog be the ones for which both the SAP Code and the Resource are in the given stream.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought about copying the stream in TabSAPLog for both Resource and SAP Code but as you point out one of the link will be inactive and I will be in exactly the same situation no?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&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;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I want 1 filter to apply on 2 columns of the same table at the same time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
    <pubDate>Thu, 20 Aug 2020 14:40:59 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-08-20T14:40:59Z</dc:date>
    <item>
      <title>Apply same filter across multiple related tables (power pivot only)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Apply-same-filter-across-multiple-related-tables-power-pivot/m-p/1310019#M22842</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to the community but I have been looking at the forum quite a lot in the past couple of months... I usually manage to find what I'm looking for but unfortunately it seems this time I'm hitting a wall or not understanding the answers... And therefore I'm making the big jump and asking my question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following data:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;And I have my relations set up as such in power pivot&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I didn't have a problem setting up the 2 fist measures using USERELATIONSHIP:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Resource Logged time on Stream SAP line := 
calculate(
  sumx(TabSAPLog, TabSAPLog[TimeLogged]),
  userelationship(TabSAPLog[SAP Code], TabSAPCode[SAP Code])
)

Stream resource Logged time on SAP line := 
calculate(
  sumx(TabSAPLog, TabSAPLog[TimeLogged]),
  userelationship(TabSAPLog[Resource], TabResources[Resource]) //this one is superfluous but best be a bit more explicit
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the problem starts when trying to calculate&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Stream Resource Logged time on Stream SAP line&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i.e., when trying to filter on a value in the TabStream table to apply to both my TabSAPCode and TabResources tables to then propagate into TabSAPLog.&lt;/P&gt;&lt;P&gt;I have been trying with CROSSFILTER but no luck (maybe I'm doing it wrong)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Stream resource logged time on Stream SAP line:=calculate(
  sumx(TabSAPLog, TabSAPLog[TimeLogged]), 
  CROSSFILTER(TabSAPLog[Resource], TabResources[Resource],Both),
  CROSSFILTER(TabSAPLog[SAP Code], TabSAPCode[SAP Code],Both) 
) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Similarly I'd also be interested in coming up with a measure doing some negative testing, i.e.,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Non Stream Resource Logged time on Stream SAP line
Stream Resource Logged time on Non-Stream SAP line&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea is of course to provide a check that only resources attributed to a given stream book time on a &lt;U&gt;stream specific&lt;/U&gt; SAP code, and &lt;U&gt;only&lt;/U&gt; on those SAP code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks for the help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Aug 2020 09:39:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Apply-same-filter-across-multiple-related-tables-power-pivot/m-p/1310019#M22842</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-23T09:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Apply same filter across multiple related tables (power pivot only)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Apply-same-filter-across-multiple-related-tables-power-pivot/m-p/1310094#M22844</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt; , make one of the join less used stream to SAP code or Stream to Resource as inactive.&amp;nbsp; and use that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or with help of merge in power query have stream populated in SAP log (Use on of smaller table&amp;nbsp;Resource or&amp;nbsp; SAP code )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;the join directly with stream&amp;nbsp; and join stream to SAP code and&amp;nbsp; Stream to Resource should be inactive or not needed&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://radacad.com/append-vs-merge-in-power-bi-and-power-query" target="_blank"&gt;https://radacad.com/append-vs-merge-in-power-bi-and-power-query&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 08:24:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Apply-same-filter-across-multiple-related-tables-power-pivot/m-p/1310094#M22844</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-08-20T08:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Apply same filter across multiple related tables (power pivot only)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Apply-same-filter-across-multiple-related-tables-power-pivot/m-p/1311537#M22900</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for a very quick response.&lt;/P&gt;&lt;P&gt;Apologies but I am having troubles following your answer.&lt;/P&gt;&lt;P&gt;One of the joint (TabSAPCode to TabSAPLog) is already inactive because precisely the filter on TabStream cannot be followed for both which is precisely what I want to achieve, i.e., I want to have a measure that when a filter is applied on TabStream[Stream] filters both TabSAPCcode and TabResource (which it does) but that then this filtering is propagated down to TabSAPLog and that the only records in TabSAPLog be the ones for which both the SAP Code and the Resource are in the given stream.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought about copying the stream in TabSAPLog for both Resource and SAP Code but as you point out one of the link will be inactive and I will be in exactly the same situation no?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&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;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I want 1 filter to apply on 2 columns of the same table at the same time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 14:40:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Apply-same-filter-across-multiple-related-tables-power-pivot/m-p/1311537#M22900</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-20T14:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Apply same filter across multiple related tables (power pivot only)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Apply-same-filter-across-multiple-related-tables-power-pivot/m-p/1316953#M23146</link>
      <description>&lt;P&gt;I managed to find a workaround but it is not really scalable to more than 2 columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Power Query, I basically:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a new Column in TabSAPLog that has all the streams&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;#"Added Column TabStream" = Table.AddColumn(TabSAPLog, "Stream Tab", each TabStream)​
#"Expanded Stream Tab" = Table.ExpandTableColumn(#"Added Column TabStream", "Stream Tab", {"Stream", "Index"}, {"Stream Tab.Stream", "Stream Tab.Index"}),​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Merge my way through TabResource and TabSAPCode to TabStream&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;#"Added Link to Resource" = Table.NestedJoin(#"Expanded Stream Tab", {"Resource"}, TabResource, {"Resource"}, "TabResource", JoinKind.LeftOuter),
#"Expanded TabResource" = Table.ExpandTableColumn(#"Added Link to Resource", "TabResource", {"Stream"}, {"Resource.Stream"}),
#"Added Link to SAP Code" = Table.NestedJoin(#"Expanded TabResource", {"SAP Code"}, TabSapCode, {"SAP Code"}, "TabSapCode", JoinKind.LeftOuter),
#"Expanded TabSapCode" = Table.ExpandTableColumn(#"Added Link to SAP Code", "TabSapCode", {"Stream"}, {"SAPCode.Stream"}),&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Build the conditional column, e.g.,&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;#"Added Both" = Table.AddColumn(
    #"Expanded TabSapCode", 
    "Stream.Index Both Resource and SAP Code", 
    each 
        if [Stream Tab.Stream] = [Resource.Stream] and [Stream Tab.Stream] = [SAPCode.Stream] then [Stream Tab.Index] 
        else null
),​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then in Power Pivot I make the links back for each of the conditional columns highlighted bleow:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;And then build my measures using USERELATIONSHIP:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Resource Logged time on Stream SAP line:=calculate(
  sumx('TabSAPLog Stream Link', 'TabSAPLog Stream Link'[TimeLogged]),
  USERELATIONSHIP(TabStream[Index], 'TabSAPLog Stream Link'[Stream.Index SAP Code inclusive])
)

Stream resource Logged time on SAP line:=calculate(
  sumx('TabSAPLog Stream Link', 'TabSAPLog Stream Link'[TimeLogged]),
  USERELATIONSHIP(TabStream[Index], 'TabSAPLog Stream Link'[Stream.Index Resource inclusive])
)

Stream resource logged time on Stream SAP line:=calculate(
  sumx('TabSAPLog Stream Link', 'TabSAPLog Stream Link'[TimeLogged]),
  USERELATIONSHIP(TabStream[Index], 'TabSAPLog Stream Link'[Stream.Index Both Resource and SAP Code])
)

Non Stream Resource Logged time on Stream SAP line:=[Resource Logged time on Stream SAP line] - [Stream resource logged time on Stream SAP line]

Stream Resource Logged time on Non-Stream SAP line:=[Stream resource Logged time on SAP line] - [Stream resource logged time on Stream SAP line]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then it actually works&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;But as mentionned it's not particularly elegant...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: this is the full powerquery statement&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;let
    Source = TabSAPLog,
    #"Added Column TabStream" = Table.AddColumn(Source, "Stream Tab", each TabStream),
    #"Expanded Stream Tab" = Table.ExpandTableColumn(#"Added Column TabStream", "Stream Tab", {"Stream", "Index"}, {"Stream Tab.Stream", "Stream Tab.Index"}),
    #"Added Link to Resource" = Table.NestedJoin(#"Expanded Stream Tab", {"Resource"}, TabResource, {"Resource"}, "TabResource", JoinKind.LeftOuter),
    #"Expanded TabResource" = Table.ExpandTableColumn(#"Added Link to Resource", "TabResource", {"Stream"}, {"Resource.Stream"}),
    #"Added Link to SAP Code" = Table.NestedJoin(#"Expanded TabResource", {"SAP Code"}, TabSapCode, {"SAP Code"}, "TabSapCode", JoinKind.LeftOuter),
    #"Expanded TabSapCode" = Table.ExpandTableColumn(#"Added Link to SAP Code", "TabSapCode", {"Stream"}, {"SAPCode.Stream"}),
    #"Added Both" = Table.AddColumn(
        #"Expanded TabSapCode", 
        "Stream.Index Both Resource and SAP Code", 
        each 
            if [Stream Tab.Stream] = [Resource.Stream] and [Stream Tab.Stream] = [SAPCode.Stream] then [Stream Tab.Index] 
            else null
    ),
    #"Added Resource Only" = Table.AddColumn(
        #"Added Both", 
        "Stream.Index Resource only", 
        each 
            if [Stream Tab.Stream] = [Resource.Stream] and [Stream Tab.Stream] &amp;lt;&amp;gt; [SAPCode.Stream] then [Stream Tab.Index] 
            else null
    ),
    #"Added SAP Code Only" = Table.AddColumn(
        #"Added Resource Only", 
        "Stream.Index SAP Code only", 
        each 
            if [Stream Tab.Stream] &amp;lt;&amp;gt; [Resource.Stream] and [Stream Tab.Stream] = [SAPCode.Stream] then [Stream Tab.Index] 
            else null
    ),
    #"Neither Resource nor SAP Code" = Table.AddColumn(
        #"Added SAP Code Only", 
        "Stream.Index Neither Resource nor SAP Code", 
        each 
            if [Stream Tab.Stream] &amp;lt;&amp;gt; [Resource.Stream] and [Stream Tab.Stream] &amp;lt;&amp;gt; [SAPCode.Stream] then [Stream Tab.Index] 
            else null
    ),
    #"SAP Code" = Table.AddColumn(
        #"Neither Resource nor SAP Code", 
        "Stream.Index SAP Code inclusive", 
        each 
            if [Stream Tab.Stream] = [SAPCode.Stream] then [Stream Tab.Index] 
            else null
    ),
    #"Resource Code" = Table.AddColumn(
        #"SAP Code", 
        "Stream.Index Resource inclusive", 
        each 
            if [Stream Tab.Stream] = [Resource.Stream] then [Stream Tab.Index] 
            else null
    ),
    #"Removed Columns" = Table.RemoveColumns(#"Resource Code",{"Stream Tab.Stream", "Resource.Stream", "SAPCode.Stream", "Stream Tab.Index"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"Stream.Index Neither Resource nor SAP Code", type number}, {"Stream.Index SAP Code only", type number}, {"Stream.Index Resource only", type number}, {"Stream.Index Both Resource and SAP Code", type number}, {"Stream.Index SAP Code inclusive", type number}, {"Stream.Index Resource inclusive", type number}})
in
    #"Changed Type"&lt;/LI-CODE&gt;&lt;P&gt;TabStream query is simply&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;let
    Source = Excel.CurrentWorkbook(),
    TabStream = Source{[Name="TabStream"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(TabStream,{{"Stream", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Reordered Columns" = Table.ReorderColumns(#"Added Index",{"Index", "Stream"})
in
    #"Reordered Columns"&lt;/LI-CODE&gt;&lt;P&gt;and same goes for TabSapCode, TabResource and TabSAPLog&lt;/P&gt;</description>
      <pubDate>Sun, 23 Aug 2020 10:29:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Apply-same-filter-across-multiple-related-tables-power-pivot/m-p/1316953#M23146</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-23T10:29:21Z</dc:date>
    </item>
  </channel>
</rss>

