<?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 Find the nearest value within a month in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-nearest-value-within-a-month/m-p/2910363#M95097</link>
    <description>&lt;P&gt;Hello community!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is anyone familiar with writing the Dax Programming to find the nearest (closest ) value in the table?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, My table is like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want to find the nearest Model built time value with 1 month average built time (in this case, today date is 2022/11/16 so&amp;nbsp;&lt;/P&gt;&lt;P&gt;(213 + 444 + 532 + 111 / 4 ) = 325 )&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;so the nearest value of 325 in this table should be 213 (A125)&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;not 345 (A124) as that model not in a past month from current date.&lt;/P&gt;&lt;P&gt;Therefore, how do i return 213 using the dax programming?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your help!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Nov 2022 18:26:31 GMT</pubDate>
    <dc:creator>heejinyune</dc:creator>
    <dc:date>2022-11-16T18:26:31Z</dc:date>
    <item>
      <title>Find the nearest value within a month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-nearest-value-within-a-month/m-p/2910363#M95097</link>
      <description>&lt;P&gt;Hello community!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is anyone familiar with writing the Dax Programming to find the nearest (closest ) value in the table?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, My table is like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want to find the nearest Model built time value with 1 month average built time (in this case, today date is 2022/11/16 so&amp;nbsp;&lt;/P&gt;&lt;P&gt;(213 + 444 + 532 + 111 / 4 ) = 325 )&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;so the nearest value of 325 in this table should be 213 (A125)&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;not 345 (A124) as that model not in a past month from current date.&lt;/P&gt;&lt;P&gt;Therefore, how do i return 213 using the dax programming?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 18:26:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-nearest-value-within-a-month/m-p/2910363#M95097</guid>
      <dc:creator>heejinyune</dc:creator>
      <dc:date>2022-11-16T18:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: Find the nearest value within a month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-nearest-value-within-a-month/m-p/2911218#M95131</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="462277" data-lia-user-login="heejinyune" class="lia-mention lia-mention-user"&gt;heejinyune&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can try the following methods&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;BR /&gt;Column:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Month = MONTH([Model built Date])&lt;/LI-CODE&gt;
&lt;P&gt;Measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Nearest Average = 
 CALCULATE(AVERAGE('Table'[Model built time]),FILTER(ALL('Table'),[Month]=MONTH(TODAY())))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Difference = ABS(SUM('Table'[Model built time])-[Nearest Average])&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Nearest Value = 
Var _mindiff=MINX(FILTER(ALL('Table'),[Month]=MONTH(TODAY())),[Difference])
Return
IF([Difference]=_mindiff,SUM('Table'[Model built time]))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Is this the result you expect?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _Charlotte&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 02:42:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-nearest-value-within-a-month/m-p/2911218#M95131</guid>
      <dc:creator>v-zhangti</dc:creator>
      <dc:date>2022-11-17T02:42:03Z</dc:date>
    </item>
  </channel>
</rss>

