<?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: Code not working in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Code-not-working/m-p/4249707#M168265</link>
    <description>&lt;P&gt;Please provide more details&amp;nbsp; - what does "not working" mean?&amp;nbsp; what does "correct" mean?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide sample data that covers your issue or question &lt;STRONG&gt;completely&lt;/STRONG&gt;, in a &lt;STRONG&gt;usable&lt;/STRONG&gt; format (not as a screenshot).&lt;BR /&gt;&lt;BR /&gt;Do not include sensitive information. Do not include anything that is unrelated to the issue or question. &lt;BR /&gt;&lt;BR /&gt;Need help uploading data? &lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;Want faster answers? &lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 20 Oct 2024 20:31:14 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2024-10-20T20:31:14Z</dc:date>
    <item>
      <title>Code not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Code-not-working/m-p/4249645#M168263</link>
      <description>&lt;P&gt;There requirement is to calculate Avg Alram per day&amp;nbsp;&lt;/P&gt;&lt;P&gt;Numerator = Total the COA Monthly by&amp;nbsp;&lt;/P&gt;&lt;P&gt;Denominator = Todays Date of the day in the month selected&amp;nbsp;&lt;/P&gt;&lt;P&gt;Exp : For current year&amp;nbsp;&lt;/P&gt;&lt;P&gt;Numerator = 100&amp;nbsp;&lt;/P&gt;&lt;P&gt;Denominator = Todays date 20 oct means... 20&amp;nbsp;&lt;/P&gt;&lt;P&gt;Exp : For past year or Historical years like for Oct&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Numerator = 100&amp;nbsp;&lt;/P&gt;&lt;P&gt;Denominator = No of days in that month like for Oct will be 31&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The code that I have written not working properly... Can any one help to get the correct results...&lt;/P&gt;&lt;P&gt;Code is ..&amp;nbsp;&lt;/P&gt;&lt;P&gt;Average Alarms Per Day (MTD) =&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR _Date = SELECTEDVALUE('Calendar'[Month-Year])&lt;/P&gt;&lt;P&gt;VAR _MonthStart = DATEVALUE(DATE(YEAR(_Date), MONTH(_Date), 1))&lt;/P&gt;&lt;P&gt;VAR _CurrentYearStart = DATEVALUE(DATE(YEAR(TODAY()), 1, 1))&lt;/P&gt;&lt;P&gt;VAR _CurrentDate = TODAY()&lt;/P&gt;&lt;P&gt;VAR DaysInMonth = DAY(EOMONTH(_MonthStart, 0))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR TotalAlarms = CALCULATE(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; [COA Monthly],&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;'Calendar'[Date] &amp;gt;= _MonthStart &amp;amp;&amp;amp; 'Calendar'[Date] &amp;lt;= IF(_Date = _CurrentDate &amp;amp;&amp;amp; _CurrentYearStart = _Date, _CurrentDate, MAX('Calendar'[Date])))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR DaysToCalculate = IF(_Date = _CurrentDate &amp;amp;&amp;amp; _CurrentYearStart = _Date, DAY(_CurrentDate), DaysInMonth)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR AverageAlarmsPerDay = DIVIDE(TotalAlarms, DaysToCalculate)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RETURN AverageAlarmsPerDay&lt;/P&gt;&lt;P&gt;Please help me with correct code&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Oct 2024 15:42:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Code-not-working/m-p/4249645#M168263</guid>
      <dc:creator>Anurag_dash</dc:creator>
      <dc:date>2024-10-20T15:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: Code not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Code-not-working/m-p/4249707#M168265</link>
      <description>&lt;P&gt;Please provide more details&amp;nbsp; - what does "not working" mean?&amp;nbsp; what does "correct" mean?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide sample data that covers your issue or question &lt;STRONG&gt;completely&lt;/STRONG&gt;, in a &lt;STRONG&gt;usable&lt;/STRONG&gt; format (not as a screenshot).&lt;BR /&gt;&lt;BR /&gt;Do not include sensitive information. Do not include anything that is unrelated to the issue or question. &lt;BR /&gt;&lt;BR /&gt;Need help uploading data? &lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;Want faster answers? &lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Oct 2024 20:31:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Code-not-working/m-p/4249707#M168265</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-10-20T20:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Code not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Code-not-working/m-p/4252234#M168401</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="828065" data-lia-user-login="Anurag_dash" class="lia-mention lia-mention-user"&gt;Anurag_dash&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please &lt;STRONG&gt;update&lt;/STRONG&gt; the formula of measure as below and check if it can return the expected result.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Average Alarms Per Day (MTD) =
VAR _Date =
    SELECTEDVALUE ( 'Calendar'[Date] )
VAR _MonthStart =
    DATEVALUE ( DATE ( YEAR ( _Date ), MONTH ( _Date ), 1 ) )
VAR _Selyear =
    YEAR ( _Date )
VAR _Selmonth =
    MONTH ( _Date )
VAR _CurrentDate =
    TODAY ()
VAR _Curyear =
    YEAR ( _CurrentDate )
VAR _Curmonth =
    MONTH ( _CurrentDate )
VAR DaysToCalculate =
    SWITCH (
        TRUE (),
        _Selyear &amp;lt; _Curyear, DAY ( EOMONTH ( _MonthStart, 0 ) ),
        _Selyear = _Curyear
            &amp;amp;&amp;amp; _Date &amp;lt;= _CurrentDate,
            IF (
                _Selmonth &amp;lt; _Curmonth,
                DAY ( EOMONTH ( _MonthStart, 0 ) ),
                DAY ( _CurrentDate )
            )
    )
VAR TotalAlarms =
    CALCULATE (
        [COA Monthly],
        'Calendar'[Date] &amp;gt;= _MonthStart
            &amp;amp;&amp;amp; 'Calendar'[Date] &amp;lt;= _Date
    )
VAR AverageAlarmsPerDay =
    DIVIDE ( TotalAlarms, DaysToCalculate )
RETURN
    AverageAlarmsPerDay&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the above one can't help you figure out, please&amp;nbsp;&lt;SPAN&gt;provide some&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;raw data&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;in your tables&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;exclude&amp;nbsp;sensitive&amp;nbsp;data&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;) with&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;&lt;SPAN&gt;format&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;and your&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:&lt;/SPAN&gt;&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-provide-sample-data-in-the-Power-BI-Forum%2Fba-p%2F963216&amp;amp;data=05%7C01%7CClaire.Dong%40microsoft.com%7Cada9149bd91546a8432508dacd31ef9b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047911607737134%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=EJlYfclgtrjgAEYj9Uo1AauqxaQm3hlQsjJMo4zCY1M%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;if you can share a&amp;nbsp;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;pbix file. You can refer the following link to upload the file to the community. Thank you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FDesktop%2FHow-to-upload-PBI-in-Community%2Fm-p%2F1672886&amp;amp;data=04%7C01%7Cv-yiruan%40microsoft.com%7C4f580813734d4a8355b008da16f6e91a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637847547341062885%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;amp;sdata=YJvujige2YITXKbKED9JieQm5LBdf%2F3IYPM4ggdiijQ%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to upload PBI in Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 08:30:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Code-not-working/m-p/4252234#M168401</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-22T08:30:25Z</dc:date>
    </item>
  </channel>
</rss>

