<?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: Compare 2 weeks in data table using 2 slicers in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-2-weeks-in-data-table-using-2-slicers/m-p/1735647#M36033</link>
    <description>&lt;P&gt;Fantastic thanks for your help&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I was able to modify the formula to get it working with my table. I had to change the ALL (in the calculate line) to reference the column as opposed to the whole table. Otherwise all individual job roles reported the total instead of the count of that role.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Comparison Week = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var _max1 = MAXX(ALLSELECTED('PERIODSW'), PERIODSW[Week Index])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var _max = MAXX(FILTER(ALL(PERIODSW), PERIODSW[Week Index] =_max1), PERIODSW[PERIODW]) //Period we want to use in fact&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;CALCULATE([Headcount],FILTER(ALL('STAFF DATA'[PERIODSW]),'STAFF DATA'[PERIODSW]=_Max))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 22 Mar 2021 06:08:49 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-03-22T06:08:49Z</dc:date>
    <item>
      <title>Compare 2 weeks in data table using 2 slicers</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-2-weeks-in-data-table-using-2-slicers/m-p/1735475#M36022</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating a HR report and one of the items I have been asked to implement is to have 2 slicers where management can compare the count of each job position, and calculate the variance between them. For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Week Values&lt;BR /&gt;Slicer 1 (&lt;SPAN&gt;'STAFF DATA'[PERIODSW]) = 2136&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Slicer 2 (&lt;/SPAN&gt;&lt;SPAN&gt;'STAFF DATA'[PERIODSW]) = 2113&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;A measure then returns the count of Staff ID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Headcount = COUNTROWS(VALUES('STAFF DATA'[ID Number]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Idealy this would enable management to see that we had 15 sales staff in week 2136, 14 sales staff in week 2113 with a net increase of 1 staff member.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can only get this to work by manually specifying the week index value (142 in the below) in the measure formula for the comparison week, but need it to be dynamic based on the user's slicer input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Headcount Prior Week = CALCULATE(COUNTROWS(VALUES('STAFF DATA'[ID Number])),ALL('STAFF DATA'[PERIODSW]),'STAFF DATA'[PERIODSW INDEX]=142)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way I can dynamically specify the index number based on the second slicer?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I know I could duplicate the data set, and prevent relationships to do this, however was hoping to avoid duplicating data where possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 04:16:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-2-weeks-in-data-table-using-2-slicers/m-p/1735475#M36022</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-22T04:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 weeks in data table using 2 slicers</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-2-weeks-in-data-table-using-2-slicers/m-p/1735502#M36026</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt; , refer to my WOW blog on how week rank can help you to solve problems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Power BI — Week on Week and WTD &lt;BR /&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.youtube.com/watch?v=pnAesWxYgJ8" target="_blank"&gt;https://www.youtube.com/watch?v=pnAesWxYgJ8&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 04:38:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-2-weeks-in-data-table-using-2-slicers/m-p/1735502#M36026</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2021-03-22T04:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 weeks in data table using 2 slicers</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-2-weeks-in-data-table-using-2-slicers/m-p/1735534#M36028</link>
      <description>&lt;P&gt;Hi amitchandak,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've actually used your "week is not so weak" post to help me address a number of issues with our 52 week reporting requirements and it has been immensely helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This problem I think is slightly different in that the end user needs the ability to select a comparison week with a slicer. It could be any week from any year with no predictable pattern.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I have a slicer from an unrelated table, that has the same weeks that correlate to the same week index number, how do I replicate that in my comparison measure?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Manual Formula Works&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Headcount Week LY (Test) = CALCULATE(COUNTROWS(VALUES('STAFF DATA'[ID Number])),FILTER(ALL('STAFF DATA'[PERIODSW]),'STAFF DATA'[PERIODSW]="2113"))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Formula stops working when attempting to link to unrelated slicer (Replaced "2113" with&amp;nbsp;&lt;SPAN&gt;SELECTEDVALUE(PERIODSW[PERIODW])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Headcount Week LY (Test) = CALCULATE(COUNTROWS(VALUES('STAFF DATA'[ID Number])),FILTER(ALL('STAFF DATA'[PERIODSW]),'STAFF DATA'[PERIODSW]=SELECTEDVALUE(PERIODSW[PERIODW])))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 05:06:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-2-weeks-in-data-table-using-2-slicers/m-p/1735534#M36028</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-22T05:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 weeks in data table using 2 slicers</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-2-weeks-in-data-table-using-2-slicers/m-p/1735565#M36029</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt; , Assume you have an independent date table and you want to use a period as a filter on Fact from week table, which is sortable (subtract -1)&lt;/P&gt;
&lt;P&gt;//Period or any column from week table is selected on slicer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This Week = &lt;BR /&gt;var _max1 = maxx(allselected('Date'), 'Date'[Week Rank])&lt;BR /&gt;var _max = maxx(filter(all('Date'),'Date'[Week Rank] =_max), 'Date'[Period]) //Period we want to use in fact &lt;BR /&gt;return &lt;BR /&gt;CALCULATE(sum('order'[Qty]), FILTER('order', 'order'[Period]=_Max ))&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Last Week = &lt;BR /&gt;var _max1 = maxx(allselected('Date'), 'Date'[Week Rank])-1&lt;BR /&gt;var _max = maxx(filter(all('Date'),'Date'[Week Rank] =_max), 'Date'[Period]) //Period we want to use in fact &lt;BR /&gt;return &lt;BR /&gt;CALCULATE(sum('order'[Qty]), FILTER('order', 'order'[Period]=_Max ))&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 05:23:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-2-weeks-in-data-table-using-2-slicers/m-p/1735565#M36029</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2021-03-22T05:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Compare 2 weeks in data table using 2 slicers</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-2-weeks-in-data-table-using-2-slicers/m-p/1735647#M36033</link>
      <description>&lt;P&gt;Fantastic thanks for your help&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I was able to modify the formula to get it working with my table. I had to change the ALL (in the calculate line) to reference the column as opposed to the whole table. Otherwise all individual job roles reported the total instead of the count of that role.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Comparison Week = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var _max1 = MAXX(ALLSELECTED('PERIODSW'), PERIODSW[Week Index])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var _max = MAXX(FILTER(ALL(PERIODSW), PERIODSW[Week Index] =_max1), PERIODSW[PERIODW]) //Period we want to use in fact&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;CALCULATE([Headcount],FILTER(ALL('STAFF DATA'[PERIODSW]),'STAFF DATA'[PERIODSW]=_Max))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 22 Mar 2021 06:08:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-2-weeks-in-data-table-using-2-slicers/m-p/1735647#M36033</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-22T06:08:49Z</dc:date>
    </item>
  </channel>
</rss>

