<?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: DAX Formula for Calculating Ratios in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Formula-for-Calculating-Ratios/m-p/3590441#M138606</link>
    <description>&lt;P&gt;&lt;SPAN&gt;To create a DAX formula for calculating the ratios based on the conditions you provided, you can use the following formula. Assuming you have columns named [Reported Date], [Classification], [Hazard], [Near Hit], and [Other], the formula would look like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ratio =&lt;BR /&gt;VAR TotalHazardNearHit = [Hazard] + [Near Hit]&lt;BR /&gt;VAR TotalOther = [Other]&lt;BR /&gt;RETURN&lt;BR /&gt;IF (&lt;BR /&gt;TotalHazardNearHit + TotalOther = 0,&lt;BR /&gt;"0:0",&lt;BR /&gt;IF (&lt;BR /&gt;TotalHazardNearHit = 0 &amp;amp;&amp;amp; TotalOther &amp;gt; 0,&lt;BR /&gt;"0:1",&lt;BR /&gt;IF (&lt;BR /&gt;TotalHazardNearHit = TotalOther,&lt;BR /&gt;"1:0",&lt;BR /&gt;CONCATENATE (&lt;BR /&gt;ROUND ( DIVIDE ( TotalHazardNearHit, TotalOther ), 1 ),&lt;BR /&gt;":1"&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This formula uses variables (TotalHazardNearHit and TotalOther) to make it easier to reference the sum of [Hazard] and [Near Hit] and [Other] in the formula. It then checks the specified conditions and returns the appropriate result based on those conditions.&lt;/P&gt;&lt;P&gt;Please replace [Hazard], [Near Hit], and [Other] with your actual column names in the formula.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Dec 2023 05:35:44 GMT</pubDate>
    <dc:creator>123abc</dc:creator>
    <dc:date>2023-12-19T05:35:44Z</dc:date>
    <item>
      <title>DAX Formula for Calculating Ratios</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Formula-for-Calculating-Ratios/m-p/3590151#M138588</link>
      <description>&lt;P&gt;Table Name is ‘Incidents_Consolidated’.&lt;/P&gt;&lt;P&gt;Column Names are [Reported Date] and [Classification]&lt;/P&gt;&lt;P&gt;The data in the [Reported Date] Column is (mm/dd/yyyy)&lt;/P&gt;&lt;P&gt;The data in the [Classification] column is text and either “Near Hit”, “Hazard” or “Other”.&lt;/P&gt;&lt;P&gt;What is the DAX formula for calculating:&lt;/P&gt;&lt;P&gt;Each Month from {Reported Date]&lt;/P&gt;&lt;P&gt;If [Hazard] + [Near Hit] + [Other] = 0 then “0:0”&lt;/P&gt;&lt;P&gt;If [Hazard] + [Near Hit] = 0 and [Other] &amp;gt; 0 “0:1”&lt;/P&gt;&lt;P&gt;If [Hazard] + [Near Hit] = [Other] then “1:0”&lt;/P&gt;&lt;P&gt;Else&lt;/P&gt;&lt;P&gt;Round(Divide(([Hazard]+[Near Hit]),[Other]),1) &amp;amp; “:1”&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 01:23:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Formula-for-Calculating-Ratios/m-p/3590151#M138588</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-12-19T01:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Formula for Calculating Ratios</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Formula-for-Calculating-Ratios/m-p/3590441#M138606</link>
      <description>&lt;P&gt;&lt;SPAN&gt;To create a DAX formula for calculating the ratios based on the conditions you provided, you can use the following formula. Assuming you have columns named [Reported Date], [Classification], [Hazard], [Near Hit], and [Other], the formula would look like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ratio =&lt;BR /&gt;VAR TotalHazardNearHit = [Hazard] + [Near Hit]&lt;BR /&gt;VAR TotalOther = [Other]&lt;BR /&gt;RETURN&lt;BR /&gt;IF (&lt;BR /&gt;TotalHazardNearHit + TotalOther = 0,&lt;BR /&gt;"0:0",&lt;BR /&gt;IF (&lt;BR /&gt;TotalHazardNearHit = 0 &amp;amp;&amp;amp; TotalOther &amp;gt; 0,&lt;BR /&gt;"0:1",&lt;BR /&gt;IF (&lt;BR /&gt;TotalHazardNearHit = TotalOther,&lt;BR /&gt;"1:0",&lt;BR /&gt;CONCATENATE (&lt;BR /&gt;ROUND ( DIVIDE ( TotalHazardNearHit, TotalOther ), 1 ),&lt;BR /&gt;":1"&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This formula uses variables (TotalHazardNearHit and TotalOther) to make it easier to reference the sum of [Hazard] and [Near Hit] and [Other] in the formula. It then checks the specified conditions and returns the appropriate result based on those conditions.&lt;/P&gt;&lt;P&gt;Please replace [Hazard], [Near Hit], and [Other] with your actual column names in the formula.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 05:35:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Formula-for-Calculating-Ratios/m-p/3590441#M138606</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-12-19T05:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Formula for Calculating Ratios</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Formula-for-Calculating-Ratios/m-p/3590802#M138628</link>
      <description>&lt;P&gt;Thanks for you response 123abc&lt;/P&gt;&lt;P&gt;I probably didn't explain the situation adequately.&lt;/P&gt;&lt;P&gt;I have a column called [Classification] within that column each entry is classified as "Hazard", "Near Hit" or "Other".&lt;/P&gt;&lt;P&gt;The [Reported_Date] column has dates in the "dd/mm/yyyy" format. I need to group by the months and for each month I need to calculate the ratio.&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 09:08:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Formula-for-Calculating-Ratios/m-p/3590802#M138628</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-12-19T09:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Formula for Calculating Ratios</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Formula-for-Calculating-Ratios/m-p/3591255#M138654</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank you for clarifying. In that case, you'll need to use the &lt;/SPAN&gt;GROUPBY&lt;SPAN&gt; and &lt;/SPAN&gt;SUMMARIZE&lt;SPAN&gt; functions in DAX to group your data by month and then apply the ratio calculations. Assuming you have a column named [Month] in your 'Incidents_Consolidated' table that represents the month extracted from the [Reported_Date], you can use the following DAX formula:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;RatioColumn =&lt;BR /&gt;VAR TotalHazardNearHit = SUMX ( VALUES ( Incidents_Consolidated[Classification] ), [Hazard] + [Near Hit] )&lt;BR /&gt;VAR TotalOther = SUMX ( VALUES ( Incidents_Consolidated[Classification] ), [Other] )&lt;BR /&gt;RETURN&lt;BR /&gt;IF (&lt;BR /&gt;TotalHazardNearHit + TotalOther = 0,&lt;BR /&gt;"0:0",&lt;BR /&gt;IF (&lt;BR /&gt;TotalHazardNearHit = 0 &amp;amp;&amp;amp; TotalOther &amp;gt; 0,&lt;BR /&gt;"0:1",&lt;BR /&gt;IF (&lt;BR /&gt;TotalHazardNearHit = TotalOther,&lt;BR /&gt;"1:0",&lt;BR /&gt;ROUND ( DIVIDE ( TotalHazardNearHit, TotalOther ), 1 ) &amp;amp; ":1"&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This formula aggregates the sum of [Hazard] + [Near Hit] and [Other] for each group (month) using the SUMX function along with the VALUES function. Then, it applies the ratio calculations based on your conditions. The result is a ratio for each month.&lt;/P&gt;&lt;P&gt;Make sure to replace [Month], [Hazard], [Near Hit], and [Other] with the actual column names in your 'Incidents_Consolidated' table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 12:51:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Formula-for-Calculating-Ratios/m-p/3591255#M138654</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-12-19T12:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Formula for Calculating Ratios</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Formula-for-Calculating-Ratios/m-p/3595311#M138904</link>
      <description>&lt;P&gt;OK, thanks for persevering with me abc123,&lt;/P&gt;&lt;P&gt;I have a table - 'Incidents_Consolidated'&lt;/P&gt;&lt;P&gt;the Coumns in the table that I'm trying to calculate are:&lt;/P&gt;&lt;P&gt;[Reported_Year], [Reported_Month] and [Classification]&lt;/P&gt;&lt;P&gt;The [Classification] Column contains data that is either:&lt;/P&gt;&lt;P&gt;"Hazard", "Near Hit" or "Other"&lt;/P&gt;&lt;P&gt;I want to calculate the ratio of "Hazard" + "Near Hit" to "Other" for each [Reported_Month] of the [Reported_Year]&lt;/P&gt;&lt;P&gt;Using the calculation:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;F (&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TotalHazardNearHit + TotalOther = 0,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"0:0",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IF (&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TotalHazardNearHit = 0 &amp;amp;&amp;amp; TotalOther &amp;gt; 0,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"0:1",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IF (&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TotalHazardNearHit = TotalOther,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"1:0",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ROUND ( DIVIDE ( TotalHazardNearHit, TotalOther ), 1 ) &amp;amp; ":1"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Many thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 03:29:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Formula-for-Calculating-Ratios/m-p/3595311#M138904</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-12-21T03:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Formula for Calculating Ratios</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Formula-for-Calculating-Ratios/m-p/3595407#M138908</link>
      <description>&lt;P&gt;Alright, I understand now. You want to group the incidents by month from the [Reported_Date] column and then calculate the ratio for each month based on the counts of "Hazard" + "Near Hit" against "Other".&lt;/P&gt;&lt;P&gt;To achieve this, follow these steps:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Create Calculated Columns for Month and Year&lt;/STRONG&gt;:&lt;UL&gt;&lt;LI&gt;Create two calculated columns in your 'Incidents_Consolidated' table to extract the month and year from the [Reported_Date] column.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Reported_Month = MONTH('Incidents_Consolidated'[Reported_Date])&lt;BR /&gt;Reported_Year = YEAR('Incidents_Consolidated'[Reported_Date])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Calculate the Ratios by Month&lt;/STRONG&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Create a new table or visualization where you group by [Reported_Year], [Reported_Month], and then apply the DAX formula to calculate the ratio.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Ratio Calculation =&lt;BR /&gt;VAR TotalHazardNearHit =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS('Incidents_Consolidated'),&lt;BR /&gt;'Incidents_Consolidated'[Classification] IN {"Hazard", "Near Hit"}&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;VAR TotalOther =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS('Incidents_Consolidated'),&lt;BR /&gt;'Incidents_Consolidated'[Classification] = "Other"&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;VAR TotalIncidents = TotalHazardNearHit + TotalOther&lt;/P&gt;&lt;P&gt;RETURN&lt;BR /&gt;IF(&lt;BR /&gt;TotalIncidents = 0,&lt;BR /&gt;"0:0",&lt;BR /&gt;IF(&lt;BR /&gt;TotalHazardNearHit = 0 &amp;amp;&amp;amp; TotalOther &amp;gt; 0,&lt;BR /&gt;"0:1",&lt;BR /&gt;IF(&lt;BR /&gt;TotalHazardNearHit = TotalOther,&lt;BR /&gt;"1:0",&lt;BR /&gt;ROUND(DIVIDE(TotalHazardNearHit, TotalOther), 1) &amp;amp; ":1"&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Visualization&lt;/STRONG&gt;:&lt;UL&gt;&lt;LI&gt;Once you have the calculated ratios, you can use a visualization tool (like Power BI, if you're using it) to display the results. For instance, you can create a bar chart where the x-axis represents the [Reported_Month] and [Reported_Year], and the y-axis displays the calculated ratios.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;By following these steps, you should be able to calculate the desired ratios grouped by month from the [Reported_Date] column.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 05:17:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Formula-for-Calculating-Ratios/m-p/3595407#M138908</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-12-21T05:17:13Z</dc:date>
    </item>
  </channel>
</rss>

