<?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 to average 2 columns and todays date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-average-2-columns-and-todays-date/m-p/3672418#M142469</link>
    <description>&lt;P&gt;Worked a treat, thank you&lt;/P&gt;</description>
    <pubDate>Thu, 01 Feb 2024 08:35:42 GMT</pubDate>
    <dc:creator>Smudgers9</dc:creator>
    <dc:date>2024-02-01T08:35:42Z</dc:date>
    <item>
      <title>DAX to average 2 columns and todays date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-average-2-columns-and-todays-date/m-p/3668068#M142224</link>
      <description>&lt;P&gt;I have a dataset which has a Created Date Column and a Completed Date column.&amp;nbsp; I need to work out the average date between the 2 but if the completion date is blank then to use todays date.&amp;nbsp; Can someone advise?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 11:06:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-average-2-columns-and-todays-date/m-p/3668068#M142224</guid>
      <dc:creator>Smudgers9</dc:creator>
      <dc:date>2024-01-30T11:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to average 2 columns and todays date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-average-2-columns-and-todays-date/m-p/3668079#M142228</link>
      <description>&lt;P&gt;&lt;SPAN&gt;To calculate the average date between the Created Date and the Completed Date columns, considering today's date if the Completed Date is blank, you can use the following DAX formula in Power BI or Power Pivot:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;AverageDate =&lt;BR /&gt;VAR TodayDate = TODAY()&lt;BR /&gt;VAR CompletionDateAdjusted = IF(ISBLANK('YourTable'[Completed Date]), TodayDate, 'YourTable'[Completed Date])&lt;BR /&gt;RETURN&lt;BR /&gt;AVERAGE('YourTable'[Created Date], CompletionDateAdjusted)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a breakdown of how the formula works:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;VAR TodayDate = TODAY(): This creates a variable TodayDate and assigns it the value of today's date.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;VAR CompletionDateAdjusted = IF(ISBLANK('YourTable'[Completed Date]), TodayDate, 'YourTable'[Completed Date]): This creates another variable CompletionDateAdjusted. If the Completed Date is blank, it assigns the value of TodayDate; otherwise, it uses the Completed Date from your dataset.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;RETURN AVERAGE('YourTable'[Created Date], CompletionDateAdjusted): This calculates the average between the Created Date and the adjusted Completion Date (either the actual Completion Date or today's date if it's blank) and returns the result.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Make sure to replace 'YourTable', 'Created Date', and 'Completed Date' with the actual names of your table and columns in your dataset. You can create a new calculated column or measure using this DAX formula depending on your requirement.&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, 30 Jan 2024 11:11:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-average-2-columns-and-todays-date/m-p/3668079#M142228</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2024-01-30T11:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to average 2 columns and todays date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-average-2-columns-and-todays-date/m-p/3668119#M142232</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="403667" data-lia-user-login="123abc" class="lia-mention lia-mention-user"&gt;123abc&lt;/a&gt;&amp;nbsp; this was a very quick response.&lt;/P&gt;&lt;P&gt;I see what the logic is trying to achieve here which is great, the only issue is my column is not listed within the IF statement, I can only select measures in replacement of my completed date column.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 11:50:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-average-2-columns-and-todays-date/m-p/3668119#M142232</guid>
      <dc:creator>Smudgers9</dc:creator>
      <dc:date>2024-01-30T11:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to average 2 columns and todays date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-average-2-columns-and-todays-date/m-p/3668354#M142237</link>
      <description>&lt;P&gt;If your Completed Date column is not listed within the IF statement and you can only select measures, it's likely because Power BI doesn't allow direct column references in measures. However, you can create a calculated column in your table to handle the logic and then reference that calculated column in your measure.&lt;/P&gt;&lt;P&gt;Here's how you can do it:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Create a Calculated Column:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Go to your table in Power BI and create a new calculated column with the following formula:&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CompletedDateAdjusted = IF(ISBLANK(YourTable[Completed Date]), TODAY(), YourTable[Completed Date])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;This formula checks if the Completed Date is blank. If it is, it uses today's date; otherwise, it uses the Completed Date from your table.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Create a Measure:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Now, you can create a measure using the calculated column you just created. Use the AVERAGEX function to calculate the average date between the Created Date and the adjusted Completed Date:&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AverageDate = AVERAGEX(YourTable, ([Created Date] + YourTable[CompletedDateAdjusted]) / 2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;This measure iterates through each row in YourTable, calculates the average date between the Created Date and the adjusted Completed Date (taking today's date if Completed Date is blank), and then computes the average across all rows.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Once you've created the calculated column and the measure, you should be able to use the AverageDate measure in your reports or visualizations to display the average date between the Created Date and the Completed Date, with today's date considered if the Completed Date is blank.&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, 30 Jan 2024 14:08:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-average-2-columns-and-todays-date/m-p/3668354#M142237</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2024-01-30T14:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to average 2 columns and todays date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-average-2-columns-and-todays-date/m-p/3669545#M142310</link>
      <description>&lt;P&gt;Hi&amp;nbsp; &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="400861" data-lia-user-login="Smudgers9" class="lia-mention lia-mention-user"&gt;Smudgers9&lt;/a&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;Here are the steps you can follow：&lt;/P&gt;
&lt;P&gt;1. Create measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure =
var _blank=
IF(
    MAX('Table'[Completed Date])=BLANK(),TODAY(),MAX('Table'[Completed Date]))
return
DATEDIFF(
    MAX('Table'[Created Date]),_blank,DAY)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Measure 2 =
AVERAGEX(
    ALL('Table'),[Measure])&lt;/LI-CODE&gt;
&lt;P&gt;2. Result:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 06:03:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-average-2-columns-and-todays-date/m-p/3669545#M142310</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-31T06:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to average 2 columns and todays date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-average-2-columns-and-todays-date/m-p/3672418#M142469</link>
      <description>&lt;P&gt;Worked a treat, thank you&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 08:35:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-average-2-columns-and-todays-date/m-p/3672418#M142469</guid>
      <dc:creator>Smudgers9</dc:creator>
      <dc:date>2024-02-01T08:35:42Z</dc:date>
    </item>
  </channel>
</rss>

