<?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 Newbie with a problem understanding code. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Newbie-with-a-problem-understanding-code/m-p/3946042#M153325</link>
    <description>&lt;P&gt;Hello everyone, I have been selected for an internship with a large company, and in this role, I am reviewing and studying the Power BI project that the corporate office has sent to our location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The project is based on the study of corporate KPIs. In the first few days, everything went smoothly, but now I am revisiting the measures, especially the CALCULATE function. I have found that many newbies have trouble immediately understanding the CALCULATE function and everything related to it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The code in question that I can't understand is this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;xx = Calculate (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; Sum('table'[y]),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; FILTER&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;( ALL ( 'table'[date]),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;'table'[date] = MAX('table'[date]) &amp;amp;&amp;amp;&amp;nbsp;'table'[date] &amp;lt;= TODAY()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How does this code return the maximum date for each month, year, and quarter?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Awaiting your help and kind response, I wish you good work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 May 2024 06:59:42 GMT</pubDate>
    <dc:creator>peraleonardo</dc:creator>
    <dc:date>2024-05-24T06:59:42Z</dc:date>
    <item>
      <title>Newbie with a problem understanding code.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Newbie-with-a-problem-understanding-code/m-p/3946042#M153325</link>
      <description>&lt;P&gt;Hello everyone, I have been selected for an internship with a large company, and in this role, I am reviewing and studying the Power BI project that the corporate office has sent to our location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The project is based on the study of corporate KPIs. In the first few days, everything went smoothly, but now I am revisiting the measures, especially the CALCULATE function. I have found that many newbies have trouble immediately understanding the CALCULATE function and everything related to it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The code in question that I can't understand is this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;xx = Calculate (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; Sum('table'[y]),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; FILTER&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;( ALL ( 'table'[date]),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;'table'[date] = MAX('table'[date]) &amp;amp;&amp;amp;&amp;nbsp;'table'[date] &amp;lt;= TODAY()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How does this code return the maximum date for each month, year, and quarter?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Awaiting your help and kind response, I wish you good work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2024 06:59:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Newbie-with-a-problem-understanding-code/m-p/3946042#M153325</guid>
      <dc:creator>peraleonardo</dc:creator>
      <dc:date>2024-05-24T06:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie with a problem understanding code.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Newbie-with-a-problem-understanding-code/m-p/3946447#M153331</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="748753" data-lia-user-login="peraleonardo" class="lia-mention lia-mention-user"&gt;peraleonardo&lt;/a&gt;&amp;nbsp;- This code will return the MAX date because it is used in conjunction with ALL().&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When ALL() is used it removes any existing filters over a table or column. CALCULATE then triggers Context Transition to re-apply the filter specified in the measure as a new filter.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are three great articles to learn some more, but also please feel free to ask me more questions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/introducing-calculate-in-dax/" target="_blank" rel="noopener"&gt;https://www.sqlbi.com/articles/introducing-calculate-in-dax/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/understanding-context-transition-in-dax/" target="_blank" rel="noopener"&gt;https://www.sqlbi.com/articles/understanding-context-transition-in-dax/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/" target="_blank"&gt;https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this has helped you enough, please accept it as the solution.&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2024 08:48:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Newbie-with-a-problem-understanding-code/m-p/3946447#M153331</guid>
      <dc:creator>mark_endicott</dc:creator>
      <dc:date>2024-05-24T08:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie with a problem understanding code.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Newbie-with-a-problem-understanding-code/m-p/3946502#M153332</link>
      <description>&lt;P&gt;The MAX function in the code will automatically calculate the maximum date outside the corresponding date range.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;xx = Calculate (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; Sum('table'[y]),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; FILTER&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;( ALL ( 'table'[date]),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;'table'[date] = &lt;STRONG&gt;MAX&lt;/STRONG&gt;('table'[date]) &amp;amp;&amp;amp;&amp;nbsp;'table'[date] &amp;lt;= TODAY()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not quite sure if I misunderstood your question.&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2024 08:58:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Newbie-with-a-problem-understanding-code/m-p/3946502#M153332</guid>
      <dc:creator>xifeng_L</dc:creator>
      <dc:date>2024-05-24T08:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie with a problem understanding code.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Newbie-with-a-problem-understanding-code/m-p/3950895#M153436</link>
      <description>&lt;P&gt;Thanks solutions from&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="738384" data-lia-user-login="xifeng_L" class="lia-mention lia-mention-user"&gt;xifeng_L&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="343036" data-lia-user-login="mark_endicott" class="lia-mention lia-mention-user"&gt;mark_endicott&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="748753" data-lia-user-login="peraleonardo" class="lia-mention lia-mention-user"&gt;peraleonardo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ALL ( 'table'[date])&lt;/LI-CODE&gt;
&lt;P&gt;Here the filter is used to apply the condition to all rows in the Table. The all function removes any filters that may be applied to the Date column of the Table, ensuring that all dates are taken into account in the calculation.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;'table'[date] = MAX('table'[date]) &amp;amp;&amp;amp; 'table'[date] &amp;lt;= TODAY()&lt;/LI-CODE&gt;
&lt;P&gt;This condition in the FILTER is to find dates in the Table that are both the largest date (the most recent date in the data) and less than or equal to today's date.&lt;BR /&gt;You can click on the drop-down link to learn the basics of the DAX:&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-quickstart-learn-dax-basics" target="_blank"&gt;Learn DAX basics in Power BI Desktop - Power BI | Microsoft Learn&lt;/A&gt;&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-Get-Your-Question-Answered-Quickly%2Fba-p%2F38490&amp;amp;data=05%7C02%7Cv-jianpengli%40microsoft.com%7Cd9552f18a0c94a7564f308dc188bf35e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638412236574903368%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=3jxUE%2BTNC8dS4DIhPphEB3NA%2BK94pwURGHu%2BXC4eezw%3D&amp;amp;reserved=0" target="_blank"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Jianpeng Li&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2024 06:26:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Newbie-with-a-problem-understanding-code/m-p/3950895#M153436</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-27T06:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie with a problem understanding code.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Newbie-with-a-problem-understanding-code/m-p/3951116#M153438</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Understood but I also have another consideration. When I try to modify the second condition and insert:&lt;/P&gt;&lt;P&gt;'table'[date] &amp;lt;= MAX(DATE(yyyy,mm,dd)) I always get in the matrix the maximum date like if the filter apply by the matrix itself it's not working.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;how can you help me out with this?&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2024 07:00:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Newbie-with-a-problem-understanding-code/m-p/3951116#M153438</guid>
      <dc:creator>peraleonardo</dc:creator>
      <dc:date>2024-05-27T07:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie with a problem understanding code.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Newbie-with-a-problem-understanding-code/m-p/3951346#M153439</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="748753" data-lia-user-login="peraleonardo" class="lia-mention lia-mention-user"&gt;peraleonardo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for your reply. This is true if you intend to take all dates into account in your calculations without taking into account any filters applied elsewhere in the report. &lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ALL ( 'table'[date])&lt;/LI-CODE&gt;
&lt;P&gt;However, if you wish to keep some filters, you may need to adjust this part of the formula. You should try using ALLEXCEPT to keep the other filters in your matrix.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/allexcept-function-dax" target="_blank"&gt;ALLEXCEPT function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/keepfilters-function-dax" target="_blank"&gt;KEEPFILTERS function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;It would be helpful if you could make some virtual data and describe the output that you are looking forward to, it would help me understand your problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-Get-Your-Question-Answered-Quickly%2Fba-p%2F38490&amp;amp;data=05%7C02%7Cv-jianpengli%40microsoft.com%7Cd9552f18a0c94a7564f308dc188bf35e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638412236574903368%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=3jxUE%2BTNC8dS4DIhPphEB3NA%2BK94pwURGHu%2BXC4eezw%3D&amp;amp;reserved=0" target="_blank"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Jianpeng Li&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2024 08:05:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Newbie-with-a-problem-understanding-code/m-p/3951346#M153439</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-27T08:05:21Z</dc:date>
    </item>
  </channel>
</rss>

