<?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 calculate how many times a combination of certain values belong to an ID in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-how-many-times-a-combination-of-certain-values/m-p/2378384#M61368</link>
    <description>&lt;P&gt;Thanks so much for your quick response and help Owen, I'm gonna try this ASAP en I'll let you know if it works!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Mar 2022 10:12:39 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-03-07T10:12:39Z</dc:date>
    <item>
      <title>How to calculate how many times a combination of certain values belong to an ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-how-many-times-a-combination-of-certain-values/m-p/2372429#M60934</link>
      <description>&lt;P&gt;Hi Everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question for my fellow BI people. I'm gonna use dummy data to give an idea of our DWH situation at our company.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So we have a Fact table Matchphases with surrogate keys linked to different dimension tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;I need to write a measure that calculates how many times Candidates have a combination of Matchphases 1, 2 AND 4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in my example the answer would be 1, cause Candidate 1 is the only one who has matchphases 1, 2 and 4 in his history of matchphases.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fact table is connected to the dimension tables using the many to one connection on the SK's:&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope someone can help me out! Thanks in advance&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 11:01:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-how-many-times-a-combination-of-certain-values/m-p/2372429#M60934</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-03T11:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate how many times a combination of certain values belong to an ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-how-many-times-a-combination-of-certain-values/m-p/2372460#M60938</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea is similar to the one discussed in &lt;A href="https://www.sqlbi.com/articles/apply-and-logic-to-multiple-selection-in-dax-slicer/" target="_blank" rel="noopener"&gt;this article on applying AND logic to multiple selections.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The difference is that you have a fixed list of MatchPhases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on your dummy data, you can adapt the measure from the above article to something like this:&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;Candidates with  MatchPhases 1,2,4 =
VAR MatchPhases = { "Matchphase 1", "Matchphase 2", "Matchphase 4" }
VAR MatchPhasesLineage =
    TREATAS ( MatchPhases, 'Dim MatchPhases'[MatchPhase_SK] )
VAR NumMatchPhases =
    COUNTROWS ( MatchPhases )
VAR CandidatesMatchPhases =
    CALCULATETABLE (
        SUMMARIZE (
            'Fact MatchPhases',
            'Dim Candidates'[Candidate_SK],
            'Dim MatchPhases'[MatchPhase_SK]
        ),
        MatchPhasesLineage
    )
VAR CandidatesWithNumMatchPhases =
    GROUPBY (
        CandidatesMatchPhases,
        'Dim Candidates'[Candidate_SK],
        "@MatchPhases", SUMX ( CURRENTGROUP (), 1 )
    )
VAR CandidatesWithAllMatchPhases =
    FILTER ( CandidatesWithNumMatchPhases, [@MatchPhases] = NumMatchPhases )
VAR Result =
    COUNTROWS ( CandidatesWithAllMatchPhases )
RETURN
    Result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The MatchPhases variable can be updated to any list of values.&lt;/P&gt;
&lt;P&gt;Does something like that work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 11:36:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-how-many-times-a-combination-of-certain-values/m-p/2372460#M60938</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2022-03-03T11:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate how many times a combination of certain values belong to an ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-how-many-times-a-combination-of-certain-values/m-p/2372612#M60947</link>
      <description>&lt;P&gt;Thanks so much for the quick response Owen! You're the man&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far the results look promising, and it works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Quick follow up question though, something I forgot to mention in my original post;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there a way to change the measure to check for candidates who have matchphase 1 AND Matchphase 2 OR 3? That would be great!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 12:37:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-how-many-times-a-combination-of-certain-values/m-p/2372612#M60947</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-03T12:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate how many times a combination of certain values belong to an ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-how-many-times-a-combination-of-certain-values/m-p/2373793#M61034</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp; you're welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;For Matchphase 1 AND Matchphase 2 OR 3, the measure is actually simpler to write.&lt;/P&gt;
&lt;P&gt;This is because we no longer need to check if every Matchphase is present from a particular set, but instead check whether any Matchpase from the first set is present, and any Matchphase from the second set is present.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do this, we can find the Candidates corresponding to two different Matchphase sets, and take the intersection.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way to write it is:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Candidates with  MatchPhases 1 and (2 or 3) = 
VAR MatchPhases_1 = { "Matchphase 1" }
VAR MatchPhases_2 = { "Matchphase 2", "Matchphase 3" }
VAR Candidates_1 =
    CALCULATETABLE (
        SUMMARIZE ( 'Fact MatchPhases','Dim Candidates'[Candidate SK] ),
        TREATAS ( MatchPhases_1, 'Dim MatchPhases'[Matchphase SK] )
    )
VAR Candidates_2 =
    CALCULATETABLE (
        SUMMARIZE ( 'Fact MatchPhases','Dim Candidates'[Candidate SK] ),
        TREATAS ( MatchPhases_2, 'Dim MatchPhases'[Matchphase SK] )
    )
RETURN
    COUNTROWS ( INTERSECT ( Candidates_1, Candidates_2 ) )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this particular example, we could also make use of Candidate SK in the fact table, and replace&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUMMARIZE ( 'Fact MatchPhases','Dim Candidates'[Candidate SK] )&lt;/LI-CODE&gt;
&lt;P&gt;with&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;VALUES ( 'Fact MatchPhases'[Candidate SK] )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2022 00:13:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-how-many-times-a-combination-of-certain-values/m-p/2373793#M61034</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2022-03-04T00:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate how many times a combination of certain values belong to an ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-how-many-times-a-combination-of-certain-values/m-p/2378384#M61368</link>
      <description>&lt;P&gt;Thanks so much for your quick response and help Owen, I'm gonna try this ASAP en I'll let you know if it works!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 10:12:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-how-many-times-a-combination-of-certain-values/m-p/2378384#M61368</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-07T10:12:39Z</dc:date>
    </item>
  </channel>
</rss>

