<?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: Converting SQL formula to DAX in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Converting-SQL-formula-to-DAX/m-p/4102702#M162800</link>
    <description>&lt;P&gt;Nevermind - I figured out the problem I was having, and converting the SQL code was the wrong way to go in this case as it didn't give me my desired output. This is the code I needed:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total Records Opened Before and Closed On or After Filtered Year (Including Null Closed Dates) = 
CALCULATE(
    COUNTROWS(YourTableName),
    ALL(YourTableName[YearColumn]),
    (
        ISBLANK(YourTableName[ClosedDate]) ||
        YEAR(YourTableName[ClosedDate]) &amp;gt;= SELECTEDVALUE(YourTableName[YearColumn])
    ),
    YEAR(YourTableName[OpenedDate]) &amp;lt;= SELECTEDVALUE(YourTableName[YearColumn])
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Aug 2024 16:32:59 GMT</pubDate>
    <dc:creator>ariam</dc:creator>
    <dc:date>2024-08-15T16:32:59Z</dc:date>
    <item>
      <title>Converting SQL formula to DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Converting-SQL-formula-to-DAX/m-p/4031067#M159423</link>
      <description>&lt;P&gt;I have a matrix table that is broken into 4 quarters using a 'date opened - year' filter on the page, and I need it to output a running total of values from previous years as well and exclude anything that has already been closed. This is the formula that a coworker wrote for when we had this on SQL (this section is just for Quarter 1 but he repeated it for each quarter):&lt;BR /&gt;&lt;BR /&gt;-- New and Continued Case Totals&lt;BR /&gt;SELECT&lt;BR /&gt;'Total number of cases (new and continued) for current quarter' AS 'CaseType',&lt;BR /&gt;(SELECT COUNT(CaseNumber) FROM temp_Continued_Q1a WHERE (YEAR(DateOpened) = caseYear) AND (MONTH(DateOpened) = 1 OR MONTH(DateOpened) = 2 OR MONTH(DateOpened) = 3) AND (DateOpened &amp;lt;= CURDATE())) +&lt;BR /&gt;(SELECT COUNT(CaseNumber) FROM temp_Continued_Q1b WHERE (DateOpened &amp;lt; CONCAT(caseYear, '-01-01') AND DateClosed IS NULL) AND (CURDATE() &amp;gt;= CONCAT(caseYear, '-01-01')) OR (DateOpened &amp;lt; CONCAT(caseYear, '-01-01') AND DateClosed &amp;gt;= CONCAT(caseYear, '-01-01')) AND (CURDATE() &amp;gt;= CONCAT(caseYear, '-01-01'))) AS Q1&lt;BR /&gt;&lt;BR /&gt;I have been trying for weeks to convert this into a DAX measure that will give me the output that I need. I tried breaking it into several measures and am able to get the first part by just doing a distinct count of the case numbers and throwing it into the matrix table, but the second part for the 'continuing' cases I cannot seem to get. I really hope someone can help me!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2024 20:45:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Converting-SQL-formula-to-DAX/m-p/4031067#M159423</guid>
      <dc:creator>ariam</dc:creator>
      <dc:date>2024-07-08T20:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Converting SQL formula to DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Converting-SQL-formula-to-DAX/m-p/4031996#M159471</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="453359" data-lia-user-login="ariam" class="lia-mention lia-mention-user"&gt;ariam&lt;/a&gt;&amp;nbsp;Hi! Can you paste some sample data and the formula? also try to explain the expected output on the data you'll paste.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2024 07:44:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Converting-SQL-formula-to-DAX/m-p/4031996#M159471</guid>
      <dc:creator>BeaBF</dc:creator>
      <dc:date>2024-07-09T07:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Converting SQL formula to DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Converting-SQL-formula-to-DAX/m-p/4102702#M162800</link>
      <description>&lt;P&gt;Nevermind - I figured out the problem I was having, and converting the SQL code was the wrong way to go in this case as it didn't give me my desired output. This is the code I needed:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total Records Opened Before and Closed On or After Filtered Year (Including Null Closed Dates) = 
CALCULATE(
    COUNTROWS(YourTableName),
    ALL(YourTableName[YearColumn]),
    (
        ISBLANK(YourTableName[ClosedDate]) ||
        YEAR(YourTableName[ClosedDate]) &amp;gt;= SELECTEDVALUE(YourTableName[YearColumn])
    ),
    YEAR(YourTableName[OpenedDate]) &amp;lt;= SELECTEDVALUE(YourTableName[YearColumn])
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 16:32:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Converting-SQL-formula-to-DAX/m-p/4102702#M162800</guid>
      <dc:creator>ariam</dc:creator>
      <dc:date>2024-08-15T16:32:59Z</dc:date>
    </item>
  </channel>
</rss>

