<?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 Calculated Column Time Intelligence in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Time-Intelligence/m-p/3320735#M124272</link>
    <description>&lt;P&gt;Good afternoon,&lt;BR /&gt;would like to return a target column that shows the Month which has higher working weeks in the selected week&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;For example target return shall be March for week 15 as of having 5 to 0 in comparing (march - april).&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;W_Days IN week = 
 
var x = CALCULATE(count('Calendar'[Month]), ALLEXCEPT('Calendar','Calendar'[Weeknum],'Calendar'[Month]),WEEKDAY('Calendar'[Date],2)&amp;lt;&amp;gt;7 &amp;amp;&amp;amp; WEEKDAY('Calendar'[Date],2)&amp;lt;&amp;gt;6) 

var y = SWITCH(TRUE(),isblank(x)=TRUE(),0,x)
return 
y&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 07 Jul 2023 15:37:15 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-07-07T15:37:15Z</dc:date>
    <item>
      <title>Calculated Column Time Intelligence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Time-Intelligence/m-p/3320735#M124272</link>
      <description>&lt;P&gt;Good afternoon,&lt;BR /&gt;would like to return a target column that shows the Month which has higher working weeks in the selected week&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;For example target return shall be March for week 15 as of having 5 to 0 in comparing (march - april).&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;W_Days IN week = 
 
var x = CALCULATE(count('Calendar'[Month]), ALLEXCEPT('Calendar','Calendar'[Weeknum],'Calendar'[Month]),WEEKDAY('Calendar'[Date],2)&amp;lt;&amp;gt;7 &amp;amp;&amp;amp; WEEKDAY('Calendar'[Date],2)&amp;lt;&amp;gt;6) 

var y = SWITCH(TRUE(),isblank(x)=TRUE(),0,x)
return 
y&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 07 Jul 2023 15:37:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Time-Intelligence/m-p/3320735#M124272</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-07-07T15:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Column Time Intelligence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Time-Intelligence/m-p/3322359#M124386</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please have a try.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Working Weeks =
VAR CurrentWeek = [Week]
VAR CurrentMonth =
    MONTH ( [Date] )
VAR NextMonth =
    MONTH ( DATE ( YEAR ( [Date] ), MONTH ( [Date] ) + 1, 1 ) )
VAR DaysInCurrentMonth =
    DAY ( EOMONTH ( [Date], 0 ) )
VAR DaysInNextMonth =
    DAY ( EOMONTH ( [Date], 1 ) )
VAR CurrentWeekDays =
    SWITCH ( CurrentWeek, 1, 7, 2, 6, 3, 5, 4, 4, 5, 3, 6, 2, 7, 1 )
VAR NextMonthDays = 7 - CurrentWeekDays
VAR CurrentMonthWorkingDays = DaysInCurrentMonth - CurrentWeekDays
VAR NextMonthWorkingDays = DaysInNextMonth - NextMonthDays
VAR WorkingWeeks =
    IF ( CurrentMonthWorkingDays &amp;gt;= 5, 5, CurrentMonthWorkingDays ) / 5
        + IF ( NextMonthWorkingDays &amp;gt;= 5, 5, NextMonthWorkingDays ) / 5
RETURN
    WorkingWeeks
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then create another column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Target Month =
VAR CurrentMonth =
    MONTH ( [Date] )
VAR NextMonth =
    MONTH ( DATE ( YEAR ( [Date] ), MONTH ( [Date] ) + 1, 1 ) )
VAR CurrentMonthWorkingWeeks = [Working Weeks]
VAR NextMonthWorkingWeeks =
    CALCULATE (
        SUM ( [Working Weeks] ),
        DATESBETWEEN (
            'Table'[Date],
            DATE ( YEAR ( 'Table'[Date] ), NextMonth, 1 ),
            DATE ( YEAR ( 'Table'[Date] ), NextMonth, 7 )
        )
    )
RETURN
    IF (
        CurrentMonthWorkingWeeks &amp;gt;= NextMonthWorkingWeeks,
        CurrentMonth,
        NextMonth
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add the "Target Month" calculated column to your visualizations to see the month with the highest number of working weeks for each week.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank" rel="noopener"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;BR /&gt;Community Support Team _ Rongtie&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 03:06:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Time-Intelligence/m-p/3322359#M124386</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-07-10T03:06:25Z</dc:date>
    </item>
  </channel>
</rss>

