<?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: Create day of week sort based on latest day in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-day-of-week-sort-based-on-latest-day/m-p/2897110#M94244</link>
    <description>&lt;P&gt;Thank you so much! This has worked perfectly! Really appreciate it!&lt;/P&gt;</description>
    <pubDate>Thu, 10 Nov 2022 09:16:11 GMT</pubDate>
    <dc:creator>Mishelski</dc:creator>
    <dc:date>2022-11-10T09:16:11Z</dc:date>
    <item>
      <title>Create day of week sort based on latest day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-day-of-week-sort-based-on-latest-day/m-p/2892027#M93903</link>
      <description>&lt;P&gt;I have a table where I am trying to create a coloumn with values from 1 to 7 based on monday to sunday and where the latest date is 1 and the day before that = 2 and so on&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used the following calculation to create this but its not doing what im expecting. Im not sure why Sat is showing as -4 rather than 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;DOW sort flag = &lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;VAR daycheck = weekday(today(),2) - 'DIM_WEEKDAY_sort'[WEEKDAY]&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;Return&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;if(daycheck = -1,6,&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;if(daycheck = 0,7,&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;if(daycheck = -2,5,&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;if(daycheck = -3,4,&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;daycheck))&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;))&lt;/EM&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appraciated&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 11:35:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-day-of-week-sort-based-on-latest-day/m-p/2892027#M93903</guid>
      <dc:creator>Mishelski</dc:creator>
      <dc:date>2022-11-08T11:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create day of week sort based on latest day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-day-of-week-sort-based-on-latest-day/m-p/2893682#M93999</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="445372" data-lia-user-login="Mishelski" class="lia-mention lia-mention-user"&gt;Mishelski&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this code to add your column:&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;DOW sort flag =
VAR _daycheck =
    WEEKDAY ( TODAY (), 2 )
RETURN
    IF (
        DIM_WEEKDAY_sort[WEEKDAY] &amp;gt;= _daycheck,
        7 - ( DIM_WEEKDAY_sort[WEEKDAY] - _daycheck ),
        _daycheck - DIM_WEEKDAY_sort[WEEKDAY]
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output:&lt;BR /&gt;&lt;BR /&gt;&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;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, please consider &lt;STRONG&gt;accepting&lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;it as the solution&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Appreciate your Kudos!!&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.credly.com/users/vahid-doustimajd/badges" target="_blank"&gt;&lt;img /&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.linkedin.com/in/vahid-dm/" target="_blank" rel="noopener noreferrer"&gt;LinkedIn&lt;/A&gt; | &lt;A href="https://twitter.com/VahidDMcom" target="_blank" rel="noopener noreferrer"&gt;Twitter&lt;/A&gt; | &lt;A href="https://www.vahiddm.com/" target="_blank" rel="noopener noreferrer"&gt;Blog&amp;nbsp;&lt;/A&gt;| &lt;A href="https://www.youtube.com/channel/UCF-uQfGF8de-EWnR9b2UQhQ" target="_blank" rel="noopener noreferrer"&gt;YouTube&lt;/A&gt;&lt;A href="https://www.youtube.com/channel/UCF-uQfGF8de-EWnR9b2UQhQ" target="_blank" rel="noopener noreferrer"&gt;&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 22:15:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-day-of-week-sort-based-on-latest-day/m-p/2893682#M93999</guid>
      <dc:creator>VahidDM</dc:creator>
      <dc:date>2022-11-08T22:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create day of week sort based on latest day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-day-of-week-sort-based-on-latest-day/m-p/2896827#M94220</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Please try this once...&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Hope it works..!!!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DOW sort flag =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;daycheck&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;= &lt;EM&gt;DIM_WEEKDAY_sort'[WEEKDAY]&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN&gt;-(&lt;/SPAN&gt;&lt;SPAN&gt;weekday&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;today&lt;/SPAN&gt;&lt;SPAN&gt;(),&lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;)-&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Return&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;daycheck&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;= -&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;6&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;daycheck&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;7&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;daycheck&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;= -&lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;daycheck&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;= -&lt;/SPAN&gt;&lt;SPAN&gt;3&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;4&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;daycheck&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 Nov 2022 07:10:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-day-of-week-sort-based-on-latest-day/m-p/2896827#M94220</guid>
      <dc:creator>amehrosh</dc:creator>
      <dc:date>2022-11-10T07:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create day of week sort based on latest day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-day-of-week-sort-based-on-latest-day/m-p/2897110#M94244</link>
      <description>&lt;P&gt;Thank you so much! This has worked perfectly! Really appreciate it!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 09:16:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-day-of-week-sort-based-on-latest-day/m-p/2897110#M94244</guid>
      <dc:creator>Mishelski</dc:creator>
      <dc:date>2022-11-10T09:16:11Z</dc:date>
    </item>
  </channel>
</rss>

