<?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: Create calculation based on date hierarchy in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-calculation-based-on-date-hierarchy/m-p/3572577#M137746</link>
    <description>&lt;P&gt;Nono, thank you very much for looking into this, this looks great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciated!&lt;/P&gt;</description>
    <pubDate>Thu, 07 Dec 2023 13:42:31 GMT</pubDate>
    <dc:creator>leandro_vegacr</dc:creator>
    <dc:date>2023-12-07T13:42:31Z</dc:date>
    <item>
      <title>Create calculation based on date hierarchy</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-calculation-based-on-date-hierarchy/m-p/3569228#M137611</link>
      <description>&lt;P&gt;Hello everyone.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset that has, among others, these columns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;object_name&lt;/TD&gt;&lt;TD&gt;uptime&lt;/TD&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;TD&gt;measure&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;obj1&lt;/TD&gt;&lt;TD&gt;95&lt;/TD&gt;&lt;TD&gt;1/12/2023&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;obj1&lt;/TD&gt;&lt;TD&gt;85&lt;/TD&gt;&lt;TD&gt;2/12/2023&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;obj2&lt;/TD&gt;&lt;TD&gt;91&lt;/TD&gt;&lt;TD&gt;1/12/2023&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;obj2&lt;/TD&gt;&lt;TD&gt;80&lt;/TD&gt;&lt;TD&gt;2/12/2023&lt;/TD&gt;&lt;TD&gt;16&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We get information from that table and display it in a data matrix. Measures are simple, for example, get distinct obj_names with an uptime greater than 90 (measure called: measured_objs), and also, from those, get objs which measure is greater than 15 (measure called normal_objs). Then, get the normal objs as a percentage of measured_objs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is fine. We display the info in a data table that has a date hierarchy; right now, measures are calculated by month, so, for example, with this data measured_objs would be 2 for Dec, and normal_objs would be 1 for Dec (only the first row). Finally, the avg would be 50 %.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, we got another requirement: calculate that avg for each day, and then, get an avg of that daily avg. So, in this case, for Dec 1 measured_obj would be 2, normal_objs would be 1 and avg would be 50 % again, but for Dec 2 measured_obj would be 0, normal_obj would be 0 also and then avg would be 0. The new measure, averaging both days, would then return 25 %.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure on how to write that measure. We got a slider that selects the month(s) to be displayed, and I just threw the measures in the datatable for them to be calculated based on the context of the datatable, which has month as the time dimension. If I expand I get the calculations for each day, but I won't get that new avg I need just from the measures I have, I think I need to write something else. How could I write something that summarizes the filtered columns in each case for each month?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 19:58:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-calculation-based-on-date-hierarchy/m-p/3569228#M137611</guid>
      <dc:creator>leandro_vegacr</dc:creator>
      <dc:date>2023-12-05T19:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create calculation based on date hierarchy</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-calculation-based-on-date-hierarchy/m-p/3572223#M137731</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="433320" data-lia-user-login="leandro_vegacr" class="lia-mention lia-mention-user"&gt;leandro_vegacr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;Here is my solution for you:&lt;/H3&gt;
&lt;H3&gt;First, create a measure that calculates the monthly average&lt;/H3&gt;
&lt;P&gt;&lt;img /&gt;&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;LI-CODE lang="markup"&gt;measure_per = var measured_objs = CALCULATE(COUNTROWS('Table'), 'Table'[uptime] &amp;gt; 90)
var normal_objs = CALCULATE(COUNTROWS('Table'), 'Table'[uptime] &amp;gt; 90, 'Table'[measure]&amp;gt;15)
return if(measured_objs &amp;gt; 0 &amp;amp;&amp;amp; normal_objs &amp;gt; 0, DIVIDE(normal_objs, measured_objs, 0), 0)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;Then, you can choose one of these methods to calculate the daily average&lt;/H3&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;daily_per1 = var _table=SUMMARIZE('Table','Table'[date],"total_value",[measure_per])
return AVERAGEX(_table,[total_value])
&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;daily_per2 = AVERAGEX('Table',[measure_per])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;Here are the result&lt;/H3&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Nono Chen&lt;/P&gt;
&lt;P&gt;If this &lt;STRONG&gt;&lt;EM&gt;post&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;helps, 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>Thu, 07 Dec 2023 10:28:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-calculation-based-on-date-hierarchy/m-p/3572223#M137731</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-12-07T10:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create calculation based on date hierarchy</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-calculation-based-on-date-hierarchy/m-p/3572577#M137746</link>
      <description>&lt;P&gt;Nono, thank you very much for looking into this, this looks great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 13:42:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-calculation-based-on-date-hierarchy/m-p/3572577#M137746</guid>
      <dc:creator>leandro_vegacr</dc:creator>
      <dc:date>2023-12-07T13:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Create calculation based on date hierarchy</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-calculation-based-on-date-hierarchy/m-p/3573072#M137759</link>
      <description>&lt;P&gt;Nono, thank you very much for your help. Just for you to know, user changed the requirement so I'm now trying to understand what to do again, so I'm creating a new post. This one was solved greatly, just for you to know the one I'm creating is not because there is a flaw with this solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 17:14:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-calculation-based-on-date-hierarchy/m-p/3573072#M137759</guid>
      <dc:creator>leandro_vegacr</dc:creator>
      <dc:date>2023-12-07T17:14:31Z</dc:date>
    </item>
  </channel>
</rss>

