<?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: Needing Help with DAX Statement in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Needing-Help-with-DAX-Statement/m-p/996782#M12550</link>
    <description>&lt;P&gt;Here's a full solution with much more than you wanted. Please play around with the visuals to understand what they are showing and calculating.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
    <pubDate>Sun, 29 Mar 2020 01:17:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-03-29T01:17:38Z</dc:date>
    <item>
      <title>Needing Help with DAX Statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Needing-Help-with-DAX-Statement/m-p/996668#M12536</link>
      <description>&lt;P&gt;Background: I'm trying to create a denominator for Patients that have a Disease Diagnosis Date on or before the time they started taking the Drug. We want to make sure to only capture with high confidence that the patients are taking the drugs we are interested in AFTER they were diagnosed with the disease we are interested in. The thought is if someone is taking a drug before their diagnosis date then they most likely were taking that drug for a different disease.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Table/Relationship Structure: Patient dimension table in the center of the schema, fact Drug table (many drugs to one patient), fact Disease table (many diseases to one patient). There is no direct relationship between Drug and Disease tables.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Silly Example - yes this isn't a disease:&amp;nbsp;&lt;BR /&gt;Drugs of Interest: Advil &amp;amp; Tylonol&lt;/P&gt;&lt;P&gt;Patient 109247 took Advil on 1/8/2020&lt;BR /&gt;Patient 109247 took Tylonol on 1/17/2020&lt;BR /&gt;Patient 109247 was diagnosed with Headache on 1/20/2020&lt;BR /&gt;This patient should not be counted in our denominator at all because they were diagnosed after taking the drugs.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;SQL:&lt;BR /&gt;SELECT Count (Distinct dr.PatientID)&lt;BR /&gt;FROM DrugTable dr&lt;BR /&gt;INNER JOIN DiseaseTable di on di.PatientID = dr.PatientID&lt;BR /&gt;WHERE dr.DrugDate &amp;gt;= di.DiseaseDate&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;DAX:&lt;BR /&gt;CALCULATE(&lt;BR /&gt;DISTINCTCOUNT(DrugTable[PatientID]),&lt;BR /&gt;FILTER (DrugTable, DrugTable[DrugDate] &amp;gt;= DiseaseTable[DiseaseDate]))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;*The Filter function is where I'm having difficulties because it can't establish a relationship between drug and disease tables. Help pls!&lt;/P&gt;</description>
      <pubDate>Sat, 28 Mar 2020 18:19:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Needing-Help-with-DAX-Statement/m-p/996668#M12536</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-28T18:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Needing Help with DAX Statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Needing-Help-with-DAX-Statement/m-p/996761#M12548</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;could you see if this measure does the trick:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;number of patients =
COUNTROWS (
    GROUPBY (
        FILTER (
            GENERATE (
                GENERATE (
                    VALUES ( Patient[PatientID] );
                    CALCULATETABLE ( VALUES ( Diagnose[diagnoseDate] ) )
                );
                CALCULATETABLE ( VALUES ( Drug[drugDate] ) )
            );
            Drug[drugDate] &amp;gt;= Diagnose[diagnoseDate]
        );
        Patient[PatientID]
    )
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have not tested it thoroughly, just used the patient you provided + one I invented myself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;BR /&gt;Sturla&lt;BR /&gt;&lt;BR /&gt;If this post helps, then please consider Accepting it as the solution. Kudos are nice too.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Mar 2020 23:19:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Needing-Help-with-DAX-Statement/m-p/996761#M12548</guid>
      <dc:creator>sturlaws</dc:creator>
      <dc:date>2020-03-28T23:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Needing Help with DAX Statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Needing-Help-with-DAX-Statement/m-p/996782#M12550</link>
      <description>&lt;P&gt;Here's a full solution with much more than you wanted. Please play around with the visuals to understand what they are showing and calculating.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Sun, 29 Mar 2020 01:17:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Needing-Help-with-DAX-Statement/m-p/996782#M12550</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-29T01:17:38Z</dc:date>
    </item>
  </channel>
</rss>

