<?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: Convert date format 'YYww' to FirstDateOfWeek in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Convert-date-format-YYww-to-FirstDateOfWeek/m-p/3489272#M133545</link>
    <description>&lt;P&gt;What is a week, in your opinion?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/weeknum-function-dax" target="_blank"&gt;WEEKNUM function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming you want to use the European system Week 07 begins on Feb 14 2022&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here, the column [Test]&amp;nbsp; has the numerical value 2207&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;FirstDateOfWeek = 
var y = 2000+ROUNDDOWN([Test]/100,0)
var w = MOD([Test],100)
var z = GENERATESERIES(Date(y,1,1),Date(y,12,31))
var a = ADDCOLUMNS(z,"wn",weeknum([Value],21))
return minx(filter(a,[wn]=w),[Value])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if you assumed the week to start on a Friday (system 15)&amp;nbsp; it would still result in Feb 11, not Feb18.&lt;/P&gt;</description>
    <pubDate>Sat, 21 Oct 2023 20:15:28 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2023-10-21T20:15:28Z</dc:date>
    <item>
      <title>Convert date format 'YYww' to FirstDateOfWeek</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Convert-date-format-YYww-to-FirstDateOfWeek/m-p/3485183#M133352</link>
      <description>&lt;P&gt;Hello, I have a column with data containing the last two digits of a year and a two digit week number. I would like to add a new column called FirstDateOfWeek where the first date of the specified week.&lt;/P&gt;&lt;P&gt;Example: 2207 should convert to 2022-02-18&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried this code that I got from ChatGPT, but it does not work.&lt;/P&gt;&lt;P&gt;Date.From(Date.From(DateTime.FromText("20" &amp;amp; Text.From([YearWeek], "00-00"), "yyyy-MM-dd")) - Duration.From(Duration.FromDays(Date.DayOfWeek(Date.From(DateTime.FromText("20" &amp;amp; Text.From([YearWeek], "00-00"), "yyyy-MM-dd")) - #datetime(2000, 12, 31, 0, 0, 0)) + Number.FromText("00-01")))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 09:17:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Convert-date-format-YYww-to-FirstDateOfWeek/m-p/3485183#M133352</guid>
      <dc:creator>spehe</dc:creator>
      <dc:date>2023-10-19T09:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date format 'YYww' to FirstDateOfWeek</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Convert-date-format-YYww-to-FirstDateOfWeek/m-p/3489272#M133545</link>
      <description>&lt;P&gt;What is a week, in your opinion?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/weeknum-function-dax" target="_blank"&gt;WEEKNUM function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming you want to use the European system Week 07 begins on Feb 14 2022&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here, the column [Test]&amp;nbsp; has the numerical value 2207&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;FirstDateOfWeek = 
var y = 2000+ROUNDDOWN([Test]/100,0)
var w = MOD([Test],100)
var z = GENERATESERIES(Date(y,1,1),Date(y,12,31))
var a = ADDCOLUMNS(z,"wn",weeknum([Value],21))
return minx(filter(a,[wn]=w),[Value])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if you assumed the week to start on a Friday (system 15)&amp;nbsp; it would still result in Feb 11, not Feb18.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Oct 2023 20:15:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Convert-date-format-YYww-to-FirstDateOfWeek/m-p/3489272#M133545</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-10-21T20:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date format 'YYww' to FirstDateOfWeek</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Convert-date-format-YYww-to-FirstDateOfWeek/m-p/3490586#M133640</link>
      <description>&lt;P&gt;Hello Ibendlin, thanks for helping me with this. As I am located in Sweden, for us, the week start on Monday, and we use system 21.&lt;BR /&gt;Adding your suggested code gives me an error message:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am totally new to DAX, and I have no idea what it means.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 07:06:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Convert-date-format-YYww-to-FirstDateOfWeek/m-p/3490586#M133640</guid>
      <dc:creator>spehe</dc:creator>
      <dc:date>2023-10-23T07:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date format 'YYww' to FirstDateOfWeek</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Convert-date-format-YYww-to-FirstDateOfWeek/m-p/3490699#M133647</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="609245" data-lia-user-login="spehe" class="lia-mention lia-mention-user"&gt;spehe&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The gpt code is for Power Query and Ibendlin's code is for a calculated column with DAX. You may also try the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;FirstWeekDate = 
VAR _year = 20&amp;amp;LEFT([date], 2)
VAR _yearstart = WEEKDAY(DATE(_year, 1, 1), 2)
VAR _week = RIGHT([date], 2)
VAR _days = _week*7 - _yearstart +1
RETURN DATE(_year, 1, 1)+_days&lt;/LI-CODE&gt;&lt;P&gt;it worked like:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;about how to add calculated columns:&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-calculated-tables" target="_blank"&gt;https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-calculated-tables&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 08:01:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Convert-date-format-YYww-to-FirstDateOfWeek/m-p/3490699#M133647</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-10-23T08:01:16Z</dc:date>
    </item>
  </channel>
</rss>

