<?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 Calculate values for Previous period for table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-for-Previous-period-for-table/m-p/2753998#M85060</link>
    <description>&lt;P&gt;Hello guys, i have a date table which give me the date of everyday starting from january 1,2022 until todays date.&lt;/P&gt;&lt;P&gt;I have a table and a timeline visual as below&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt; the pic is a bit blurred for some reason but the timeline visual is like a date slicer. You can choose between year, day, month or week to choose the desired date just like a slicer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While the table contains line description and financial value with the formula:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Financial Value =&lt;/P&gt;&lt;P&gt;&amp;nbsp;SWITCH(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; SELECTEDVALUE('Sort Table'[line description]),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Minutes Expenses",[ Minute expenses],&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Total Expenses",[ total Expenses]&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Business Expenses",[ Business Expenses],&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Payroll Expenses",[ Payroll Expenses],&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Revenue",[ Total revenue],&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Taxes",[ Total revenue]*taxes]),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Net Profit" , [Net profit]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add a new measure that gives me the previous period shatever timeline i chosoe weather its month, week, or day i want it to give me the alst period. For instance if i choose the day timeline slicer and select 08/01/2022 i want the result of the previous period to be 07/31/2022. Or if i choose the month timeline slicer and choose august 2022 i want to see the previous values of july 2022.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Sep 2022 23:45:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-09-07T23:45:47Z</dc:date>
    <item>
      <title>Calculate values for Previous period for table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-for-Previous-period-for-table/m-p/2753998#M85060</link>
      <description>&lt;P&gt;Hello guys, i have a date table which give me the date of everyday starting from january 1,2022 until todays date.&lt;/P&gt;&lt;P&gt;I have a table and a timeline visual as below&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt; the pic is a bit blurred for some reason but the timeline visual is like a date slicer. You can choose between year, day, month or week to choose the desired date just like a slicer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While the table contains line description and financial value with the formula:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Financial Value =&lt;/P&gt;&lt;P&gt;&amp;nbsp;SWITCH(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; SELECTEDVALUE('Sort Table'[line description]),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Minutes Expenses",[ Minute expenses],&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Total Expenses",[ total Expenses]&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Business Expenses",[ Business Expenses],&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Payroll Expenses",[ Payroll Expenses],&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Revenue",[ Total revenue],&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Taxes",[ Total revenue]*taxes]),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; "Net Profit" , [Net profit]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add a new measure that gives me the previous period shatever timeline i chosoe weather its month, week, or day i want it to give me the alst period. For instance if i choose the day timeline slicer and select 08/01/2022 i want the result of the previous period to be 07/31/2022. Or if i choose the month timeline slicer and choose august 2022 i want to see the previous values of july 2022.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 23:45:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-for-Previous-period-for-table/m-p/2753998#M85060</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-07T23:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate values for Previous period for table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-for-Previous-period-for-table/m-p/2754117#M85069</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , I would recommend using calculation group for this case &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calculation Groups- Measure Slicer, Measure Header Grouping, Measure to dimension conversion. Complex Table display : &lt;A href="https://youtu.be/qMNv67P8Go0" target="_blank"&gt;https://youtu.be/qMNv67P8Go0 &lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;refer these Switch examples&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Switch Period = &lt;BR /&gt;var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())&lt;BR /&gt;var _max = &lt;BR /&gt;SWITCH(SELECTEDVALUE(Period[PeriodType],"MTD"),&lt;BR /&gt;"YTD",_max1,&lt;BR /&gt;"FYTD",_max1,&lt;BR /&gt;"QTD",_max1,&lt;BR /&gt;"MTD",_max1,&lt;BR /&gt;"This Month",eomonth(_max,0),&lt;BR /&gt;"LMTD",date(Year(_max), month(_max) -1, Day(_max)),&lt;BR /&gt;"Last Month",eomonth(_max,-1),&lt;BR /&gt;"WTD", _max1,&lt;BR /&gt;"Cumm",_max1,&lt;BR /&gt;"Rolling 3", _max1,&lt;BR /&gt;"Rolling 6", _max1,&lt;BR /&gt;"Rolling 12",_max1,&lt;BR /&gt;"Rolling 7 Day",_max1,&lt;BR /&gt;"Yesterday",_max1-1,&lt;BR /&gt;BLANK())&lt;/P&gt;
&lt;P&gt;var _min =&lt;BR /&gt;SWITCH(SELECTEDVALUE(Period[PeriodType],"MTD"),&lt;BR /&gt;"YTD",eomonth(_max,-1*MONTH(_max))+1 , //FY April -March&lt;BR /&gt;"FYTD",if( Month(_max) &amp;lt;4 , date(year(_max)-1,4,1) ,date(year(_max),4,1)), //FY April -March&lt;BR /&gt;"QTD",eomonth(_max,-1* if( mod(Month(_max),3) =0,3,mod(Month(_max),3)))+1,&lt;BR /&gt;"MTD",eomonth(_max,-1)+1 ,&lt;BR /&gt;"This Month",eomonth(_max,-1)+1 ,&lt;BR /&gt;"LMTD",eomonth(_max,-1)+1,&lt;BR /&gt;"Last Month",eomonth(_max,-1)+1,&lt;BR /&gt;"WTD", _max -WEEKDAY(_max,2)+1,&lt;BR /&gt;"Cumm", Minx(ALLSELECTED('Date'),'Date'[Date]),&lt;BR /&gt;"Rolling 3", date(Year(_max), month(_max) -3, Day(_max))+1,&lt;BR /&gt;"Rolling 6", date(Year(_max), month(_max) -6, Day(_max))+1,&lt;BR /&gt;"Rolling 12", date(Year(_max), month(_max) -12, Day(_max))+1,&lt;BR /&gt;"Rolling 7 Day", date(Year(_max), month(_max) , Day(_max)-7),&lt;BR /&gt;"Yesterday",_max1-1&lt;BR /&gt;BLANK())&lt;BR /&gt;return&lt;BR /&gt;CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Switch Period = &lt;BR /&gt;var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())&lt;BR /&gt;var _min =&lt;BR /&gt;SWITCH(SELECTEDVALUE(Period[PeriodType],"MTD"),&lt;BR /&gt;"YTD",eomonth(_max,-1*MONTH(_max))+1 , //FY April -March&lt;BR /&gt;"LYTD",eomonth(_max,-1*MONTH(_max))+1 ,&lt;BR /&gt;"FYTD",if( Month(_max) &amp;lt;4 , date(year(_max)-1,4,1) ,date(year(_max),4,1)), //FY April -March&lt;BR /&gt;"QTD",eomonth(_max,-1* if( mod(Month(_max),3) =0,3,Month(_max)))+1,&lt;BR /&gt;"MTD",eomonth(_max,-1)+1 ,&lt;BR /&gt;"LMTD",eomonth(_max,-1)+1 ,&lt;BR /&gt;"LYMTD",eomonth(_max,-1)+1 ,&lt;BR /&gt;"WTD", _max -WEEKDAY(_max,2)+1,&lt;BR /&gt;"Cumm", Minx(ALLSELECTED('Date'),'Date'[Date]),&lt;BR /&gt;"Rolling 3", date(Year(_max), month(_max) -3, Day(_max))+1,&lt;BR /&gt;"Rolling 6", date(Year(_max), month(_max) -6, Day(_max))+1,&lt;BR /&gt;"Rolling 12", date(Year(_max), month(_max) -12, Day(_max))+1,&lt;BR /&gt;BLANK())&lt;BR /&gt;var _max1 = SWITCH(SELECTEDVALUE(Period[PeriodType],"MTD") ,&lt;BR /&gt;"LYTD",Date(Year(_max)-1, month(_max), Day(_max))&lt;BR /&gt;"LMTD",Date(Year(_max), month(_max)-1, Day(_max))&lt;BR /&gt;"LYMTD",Date(Year(_max)-1, month(_max), Day(_max) ) ,&lt;BR /&gt;_max)&lt;BR /&gt;var _min1 = SWITCH(SELECTEDVALUE(Period[PeriodType],"MTD") ,&lt;BR /&gt;"LYTD",Date(Year(_min)-1, month(_min), Day(_min))&lt;BR /&gt;"LMTD",Date(Year(_min), month(_min)-1, Day(_min))&lt;BR /&gt;"LYMTD",Date(Year(_min)-1, month(_min), Day(_min) ) ,&lt;BR /&gt;_min)&lt;BR /&gt;return&lt;BR /&gt;CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min1,_max1))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Power BI — Month on Month with or Without Time Intelligence &lt;BR /&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.youtube.com/watch?v=6LUBbvcxtKA" target="_blank"&gt;https://www.youtube.com/watch?v=6LUBbvcxtKA&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 02:21:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-values-for-Previous-period-for-table/m-p/2754117#M85069</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-09-08T02:21:52Z</dc:date>
    </item>
  </channel>
</rss>

