<?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: How to use Stage field from child table to slice amount in parent table in a many-to-many in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/747021#M2538</link>
    <description>&lt;P&gt;Hi there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for not having answered earlier but I was on hols out of the country. Only back today. I'll have a look at your file and see what the issue is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jul 2019 18:30:31 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-07-23T18:30:31Z</dc:date>
    <item>
      <title>How to use Stage field from child table to slice amount in parent table in a many-to-many</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/740472#M2247</link>
      <description>&lt;P&gt;I created a table (named: Snapshot 1) using Salesforce opportunity data where a snapshot is captured every 1st of each month and tagged every record with Snapshot Date (e.g. 4/1/2019, 5/1/2019, etc.). I then duplicated Snapshot 1 as Snapshot 2 and joined them using opportunity id field, many-to-many cardinality, single cross-filter direction, Snapshot 1 filters Snapshot 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 2 snapshot date slicers - one for Snapshot 1 and another one for Snapshot 2. In my testing, I set Snapshot 1 filter to 7/1/2019 and Snapshot 2 filter to 4/1/2019. I also filtered Snapshot 1 stage = Closed-Won. I then created a matrix with Opportunity Stage from Snapshot 2 in Rows and Opportunity Stage from Snapshot 1 in Columns. I then added the amount field from both snapshot tables to Values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here’s a screenshot of the resulting table. I’m getting the correct amounts from Snapshot 2 (since S1 filters S2). But in the Snapshot 1 amount column, I couldn’t split the amount (total won of 23.9M) among the stages from Snapshot 2. Basically, I want to know the composition of the 23.9M won deals in July based on what the stage was back in April.&lt;/P&gt;&lt;P&gt;Here’s my current measure: CALCULATE(SUM(‘Opportunity Snapshots 1’[Line Amount]))&lt;BR /&gt;How do I modify this so that the Snapshot 1 amount gets filtered by the Snapshot 2 stages?&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;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ferdinand&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 23:30:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/740472#M2247</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-15T23:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Stage field from child table to slice amount in parent table in a many-to-many</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/741319#M2286</link>
      <description>&lt;P&gt;Before you start using many-to-many just please make sure YOU DO UNDERSTAND HOW THEY WORK and what the pitfalls are. Because trust me: THERE ARE MANY.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The best way to implement many-to-many is to have two tables that serve as dimensions and then a bridge table between them. This is the best design by far. Using many-to-many in Power BI is tricky and you're not even probably aware of all the gotchas.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 16:16:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/741319#M2286</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-16T16:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Stage field from child table to slice amount in parent table in a many-to-many</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/741398#M2291</link>
      <description>&lt;P&gt;Thanks for the advice darlove.&amp;nbsp; The bridge approach was actually the first approach I tried where I created a table of unique ids and linked both files to it.&amp;nbsp; I wasn't able to get the desired outcome so I'm trying the many-to-many join, one way, this time.&amp;nbsp; Here's a representation of the result I'm trying to get.&amp;nbsp; I'm hoping I only need the correct dax measure.&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;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ferdinand&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 17:57:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/741398#M2291</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-16T17:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Stage field from child table to slice amount in parent table in a many-to-many</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/741692#M2298</link>
      <description>&lt;P&gt;Hi there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've done it but... without a many-to-many of any kind. Here's the result:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Here is the model:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The S2 Additional Stage and S1 Additional Stage tables are hidden and they only store the stage of Non-Existent (see the report where you see Non-Existent instead of BLANK; yes, there are no (blank)'s in the report any more). I needed them to add the Non-Existent entry into the S1 Stages and S2 Stages tables in Power Query. Note that S2 Stages and S2 Snapshot Date have &lt;STRONG&gt;inactive&lt;/STRONG&gt; relationships with the Snapshot table. I could have enabled them but I don't think it would be correct in any way in this model.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the tables' &lt;STRONG&gt;visible&lt;/STRONG&gt; fields:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The fields in Snapshot that link to the other tables have been hidden. You should not slice by them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course, to create the dimensions I used Power Query to extract the right data from the columns of Snapshot and make it unique.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the measures:&lt;/P&gt;&lt;PRE&gt;S1 Amount = 
var __isS2NonExistentStageVisible = 
    NOT ISEMPTY(
        FILTER(
            'S2 Stages',
            'S2 Stages'[S2 Stage] = "Non-Existent"
        )
    )
var __relevantIds =
    CALCULATETABLE(
        SUMMARIZE(
            Snapshot,
            Snapshot[Id]
        ),
        USERELATIONSHIP('S2 Snapshot Date'[Date], Snapshot[Date] ),
        USERELATIONSHIP('S2 Stages'[S2 Stage], Snapshot[Stage] ),
        ALL( 'S1 Snapshot Date' ),
        ALL( 'S1 Stages' )
    )
var __allIdsThatHaveS2Stage =
    CALCULATETABLE(
        SUMMARIZE(
            Snapshot,
            Snapshot[Id]
        ),
        USERELATIONSHIP('S2 Snapshot Date'[Date], Snapshot[Date] ),
        ALLEXCEPT( Snapshot, 'Unique IDs' )
    )
var __resultWithoutNonExistent =
    CALCULATE(
        SUM( Snapshot[Amount] ),
        INTERSECT(
            VALUES( Snapshot[Id] ),
            __relevantIds
        )
    )
var __resultWithNonExistent =
    CALCULATE(
        SUM( Snapshot[Amount] ),
        EXCEPT(
            VALUES( Snapshot[Id] ),
            __allIdsThatHaveS2Stage
        )
    )
var __result =
    __resultWithoutNonExistent +
        if( __isS2NonExistentStageVisible, __resultWithNonExistent )
return
    __result&lt;/PRE&gt;&lt;PRE&gt;S2 Amount = 
var __isS1NonExistentStageVisible = 
    NOT ISEMPTY(
        FILTER(
            'S1 Stages',
            'S1 Stages'[S1 Stage] = "Non-Existent"
        )
    )
var __relevantS1Ids =
    SUMMARIZE(
        Snapshot,
        Snapshot[Id]
    )
var __allIdsThatHaveS1Stage =
    CALCULATETABLE(
        SUMMARIZE(
            Snapshot,
            Snapshot[Id]
        ),
        ALL( 'S1 Stages' )
    )
var __visibleS2Ids =
    CALCULATETABLE(
        VALUES( Snapshot[Id] ),
        USERELATIONSHIP( Snapshot[Stage], 'S2 Stages'[S2 Stage] ),
        USERELATIONSHIP( Snapshot[Date], 'S2 Snapshot Date'[Date] ),
        ALLEXCEPT( Snapshot, 'Unique IDs' )
    )
var __resultWithoutNonExistent =
    CALCULATE(
        SUM( Snapshot[Amount] ),
        INTERSECT(
            __visibleS2Ids,
            __relevantS1Ids
        ),
        USERELATIONSHIP( Snapshot[Stage], 'S2 Stages'[S2 Stage] ),
        USERELATIONSHIP( Snapshot[Date], 'S2 Snapshot Date'[Date] ),
        ALL( 'S1 Snapshot Date' ),
        All( 'S1 Stages' )
    )
var __resultWithNonExistent =
    CALCULATE(
        SUM( Snapshot[Amount] ),
        EXCEPT(
            __visibleS2Ids,
            __allIdsThatHaveS1Stage
        ),
        USERELATIONSHIP( Snapshot[Stage], 'S2 Stages'[S2 Stage] ),
        USERELATIONSHIP( Snapshot[Date], 'S2 Snapshot Date'[Date] ),
        ALL( 'S1 Snapshot Date' ),
        All( 'S1 Stages' )
    )
var __result =
    __resultWithoutNonExistent +
        if( __isS1NonExistentStageVisible, __resultWithNonExistent )
return
    __result&lt;/PRE&gt;&lt;P&gt;I don't know how performant this code is. You have to check it yourself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 02:55:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/741692#M2298</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-17T02:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Stage field from child table to slice amount in parent table in a many-to-many</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/745071#M2463</link>
      <description>&lt;P&gt;Thank you so much Darek! Do you mind sharing the pbix file please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ferdinand&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jul 2019 07:59:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/745071#M2463</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-21T07:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Stage field from child table to slice amount in parent table in a many-to-many</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/746004#M2498</link>
      <description>&lt;P&gt;Hi Darek,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried your solution and it somehow didn't work using my actual data.&amp;nbsp; And this is my bad.&amp;nbsp; I have over-simplified the data sample I provided.&amp;nbsp; Below is the link to my pbix file where my workaround is to use 3 separate visuals.&amp;nbsp; This has actual data source.&amp;nbsp; You seem very well-versed in DAX and I'm hoping you can help me find a way to show these in a single matrix table (instead of 3).&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Link to pbix: &lt;A href="https://drive.google.com/file/d/1KkMZsb-SK39InNKj9BlLgIYEWZLF-3in/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/1KkMZsb-SK39InNKj9BlLgIYEWZLF-3in/view?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ferdinand&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 23:36:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/746004#M2498</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-22T23:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Stage field from child table to slice amount in parent table in a many-to-many</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/747021#M2538</link>
      <description>&lt;P&gt;Hi there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for not having answered earlier but I was on hols out of the country. Only back today. I'll have a look at your file and see what the issue is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 18:30:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/747021#M2538</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-23T18:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Stage field from child table to slice amount in parent table in a many-to-many</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/747067#M2543</link>
      <description>&lt;P&gt;No worries Darek.&amp;nbsp; I really appreciate your help on this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ferdie&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 19:34:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-use-Stage-field-from-child-table-to-slice-amount-in/m-p/747067#M2543</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-23T19:34:51Z</dc:date>
    </item>
  </channel>
</rss>

