<?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: Help required to write a DAX measure in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-required-to-write-a-DAX-measure/m-p/3412723#M129040</link>
    <description>&lt;P&gt;Alright, let's break this down. You want to calculate the number of accident IDs for each camera based on the camera installation date. Specifically, you want to count the number of accidents that occurred 3 months before and 3 months after the camera installation date.&lt;/P&gt;
&lt;P&gt;First, we need to get the installation date for each camera. Since the Cam Details table has the Camera Installation Date, and it's linked to the Camera table through Camera ID, we can use the RELATED function to get the installation date for each camera.&lt;/P&gt;
&lt;P&gt;Now, for the measure to count the accidents 3 months before and after the installation date, we'll use the FILTER function to filter the Accidents table based on the date range we want. The DATEADD function will be useful here to calculate the date range.&lt;/P&gt;
&lt;P&gt;Here's how you can write the measure:&lt;/P&gt;
&lt;P&gt;Accidents Around Installation :=&lt;BR /&gt;VAR InstallationDate = RELATED('Cam Details'[Camera Installation Date])&lt;BR /&gt;VAR StartDate = DATEADD(InstallationDate, -3, MONTH)&lt;BR /&gt;VAR EndDate = DATEADD(InstallationDate, 3, MONTH)&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNT('Accidents'[Accident ID]),&lt;BR /&gt;FILTER(&lt;BR /&gt;'Accidents',&lt;BR /&gt;'Accidents'[Date] &amp;gt;= StartDate &amp;amp;&amp;amp; 'Accidents'[Date] &amp;lt;= EndDate&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;This measure first determines the installation date for the current context's camera. It then calculates the start and end dates for our 3-month window. Finally, it counts the number of accidents that fall within this date range.&lt;/P&gt;
&lt;P&gt;You can add this measure to a visual or table that has the Camera ID in context, and it should give you the count of accidents for each camera based on its installation date.&lt;/P&gt;</description>
    <pubDate>Sun, 03 Sep 2023 17:38:08 GMT</pubDate>
    <dc:creator>technolog</dc:creator>
    <dc:date>2023-09-03T17:38:08Z</dc:date>
    <item>
      <title>Help required to write a DAX measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-required-to-write-a-DAX-measure/m-p/3304979#M123416</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some help in the model and writing a measure. I need to write 2 measures to calculate the number of accident ids for each camera based on camera installation date i.e number of accident ids for 3 months before and 3 months after the camera installation date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Camera table and Accident table are both fact tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Model:&lt;/P&gt;&lt;P&gt;Camera table- Camera ID and Date columns&lt;/P&gt;&lt;P&gt;Cam Detailts- Camera ID, Camera Installation Date, Road name and other details&lt;/P&gt;&lt;P&gt;Metadata- Road name and other details&lt;/P&gt;&lt;P&gt;Accident ODDs- Accident short name and Road name&lt;/P&gt;&lt;P&gt;Accidents- Date,&amp;nbsp;Accident short name, Accident ID&lt;/P&gt;&lt;P&gt;Calendar- Dimension table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Relationships:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Camera table and Cam details - linked on Camera ID&lt;/P&gt;&lt;P&gt;Cam details and Metadata- linked on Road name&lt;/P&gt;&lt;P&gt;Metadata and Accident ODDs - linked on Road name&lt;/P&gt;&lt;P&gt;Accident ODDs and Accidents- linked on Accident short name&lt;/P&gt;&lt;P&gt;Accidents and Calendar- linked on date field&lt;/P&gt;&lt;P&gt;Calendar and&amp;nbsp;Camera table - linked on date field&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i write the measure I am not able write the filter condition to check the dates. Please help.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2023 18:52:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-required-to-write-a-DAX-measure/m-p/3304979#M123416</guid>
      <dc:creator>Cevola</dc:creator>
      <dc:date>2023-06-27T18:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Help required to write a DAX measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-required-to-write-a-DAX-measure/m-p/3412723#M129040</link>
      <description>&lt;P&gt;Alright, let's break this down. You want to calculate the number of accident IDs for each camera based on the camera installation date. Specifically, you want to count the number of accidents that occurred 3 months before and 3 months after the camera installation date.&lt;/P&gt;
&lt;P&gt;First, we need to get the installation date for each camera. Since the Cam Details table has the Camera Installation Date, and it's linked to the Camera table through Camera ID, we can use the RELATED function to get the installation date for each camera.&lt;/P&gt;
&lt;P&gt;Now, for the measure to count the accidents 3 months before and after the installation date, we'll use the FILTER function to filter the Accidents table based on the date range we want. The DATEADD function will be useful here to calculate the date range.&lt;/P&gt;
&lt;P&gt;Here's how you can write the measure:&lt;/P&gt;
&lt;P&gt;Accidents Around Installation :=&lt;BR /&gt;VAR InstallationDate = RELATED('Cam Details'[Camera Installation Date])&lt;BR /&gt;VAR StartDate = DATEADD(InstallationDate, -3, MONTH)&lt;BR /&gt;VAR EndDate = DATEADD(InstallationDate, 3, MONTH)&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNT('Accidents'[Accident ID]),&lt;BR /&gt;FILTER(&lt;BR /&gt;'Accidents',&lt;BR /&gt;'Accidents'[Date] &amp;gt;= StartDate &amp;amp;&amp;amp; 'Accidents'[Date] &amp;lt;= EndDate&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;This measure first determines the installation date for the current context's camera. It then calculates the start and end dates for our 3-month window. Finally, it counts the number of accidents that fall within this date range.&lt;/P&gt;
&lt;P&gt;You can add this measure to a visual or table that has the Camera ID in context, and it should give you the count of accidents for each camera based on its installation date.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Sep 2023 17:38:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-required-to-write-a-DAX-measure/m-p/3412723#M129040</guid>
      <dc:creator>technolog</dc:creator>
      <dc:date>2023-09-03T17:38:08Z</dc:date>
    </item>
  </channel>
</rss>

