<?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: Get previous month / previous year using calculation groups in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-month-previous-year-using-calculation-groups/m-p/3479903#M133003</link>
    <description>&lt;P&gt;What is the business problem you are trying to solve?&lt;/P&gt;</description>
    <pubDate>Tue, 17 Oct 2023 00:18:40 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2023-10-17T00:18:40Z</dc:date>
    <item>
      <title>Get previous month / previous year using calculation groups</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-month-previous-year-using-calculation-groups/m-p/3477393#M132876</link>
      <description>&lt;P&gt;Hi all!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Sorry for the long post but I am kinda stuck at the moment. Hear me out.&lt;BR /&gt;&lt;BR /&gt;I am developing a report that has the following requirements:&lt;BR /&gt;&lt;BR /&gt;1.&amp;nbsp;&lt;STRONG&gt;2 slicers&lt;/STRONG&gt; (Slicer A &amp;amp; Slicer B),&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&amp;nbsp;&lt;BR /&gt;2. &lt;STRONG&gt;2 date ranges&lt;/STRONG&gt; for the custom options in Slicers A and B,&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3.&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;6 card visuals, and 3 filters&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Field used for Card Visual 1 : Column ABC&lt;BR /&gt;Field used for Card Visual 2:&amp;nbsp; Column DEF (this is basically column ABC but I created a measure to capture its data separately and use for Card Visual 2)&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The&lt;STRONG&gt; goal of the report is to have 2 separate values that will display on the Card Visuals.&lt;/STRONG&gt; For example, if user selects Last 7 Days in Slicer 1 and Month over Month in Slicer 2, the Card 1 will show total values from the last 7 days while Card 2 will show the last 7 days total but 1 month prior, etc. Also, the date range slicers will only be usable if the CUSTOM option is selected for each slicer.&lt;BR /&gt;&lt;BR /&gt;I tried these ff approaches:&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Approach 1: Hard coding all (including the date ranges) inside the measures&lt;/STRONG&gt;&lt;BR /&gt;1. Hard code the calculations inside the measures used for Card Visuals 1 &amp;amp; 2,&lt;BR /&gt;2. Create a dummy table for Slicers A and B to contain the fields that will serve as switch case triggers for the hard-coded values.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Initially I thought this is good but I had an issue on the Custom option.However I could not make this calculation work when trying to get the Month over Month / Year over Year values. (I am using DAX function PARALLELPERIOD in Slicer B. )&lt;BR /&gt;&lt;BR /&gt;Here is the calculation I used for capturing Custom in Slicer A.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Note: I used DAX function USERELATIONSHIP in capturing the value for Custom in Slicer A. Part of the goal is that the date range will only function once Custom is selected in Slicer A. This is the part where I am stuck in this approach.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Approach 2: Use calculation groups&lt;BR /&gt;&lt;/STRONG&gt;I tried to use calculation groups using the same logic I did in Approach 1.&lt;BR /&gt;Slicer A calculation group is working fine.&lt;BR /&gt;Slicer B calculation group is not working because I do not know how to implement a calculation group to interact on select measures.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;My question: Is Approach 2 better than Approach 1?&lt;/STRONG&gt; If yes, can someone point me in the right direction? I am just using DAX function PARALLELPERIOD in getting the Month over Month and Year over Year values in Slicer B.&lt;BR /&gt;&lt;BR /&gt;Note 2: Sorry could not provide pbix since report is inside CITRIX env.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Many thanks,&amp;nbsp;&lt;BR /&gt;- ja1meee&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Oct 2023 15:20:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-month-previous-year-using-calculation-groups/m-p/3477393#M132876</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-15T15:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get previous month / previous year using calculation groups</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-month-previous-year-using-calculation-groups/m-p/3479903#M133003</link>
      <description>&lt;P&gt;What is the business problem you are trying to solve?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 00:18:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-month-previous-year-using-calculation-groups/m-p/3479903#M133003</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-10-17T00:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Get previous month / previous year using calculation groups</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-month-previous-year-using-calculation-groups/m-p/3480014#M133010</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;&amp;nbsp;, the client wants to compare the values generated from Slicer A from Slicer B.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I was able to create a Calculation group with for Slicer A with the following measures:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Calculation Group for Slicer A&lt;/DIV&gt;&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Calculation Group for Slicer A&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;// 7 Days&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;VAR __Isdatesfiltered =&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; CALCULATE ( ISFILTERED ( 'dim_date'[date] ), ALLSELECTED () )&lt;/DIV&gt;&lt;DIV&gt;VAR __date =&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; CALCULATE (MAX ( 'fact_table'[Date] ),&amp;nbsp;REMOVEFILTERS ()&amp;nbsp;)&lt;/DIV&gt;&lt;DIV&gt;VAR __Result =&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; IF (&amp;nbsp;__Isdatesfiltered,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SELECTEDMEASURE (),&amp;nbsp;CALCULATE (&amp;nbsp;SELECTEDMEASURE (),&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; KEEPFILTERS (DATESINPERIOD ( 'dim_date'[date], __date - 1, -7, DAY )&amp;nbsp;)&amp;nbsp;)&amp;nbsp;)&lt;/DIV&gt;&lt;DIV&gt;RETURN&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; __Result&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;// Last Month&lt;/DIV&gt;&lt;DIV&gt;VAR __Isdatesfiltered =&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; CALCULATE ( ISFILTERED ( 'dim_date'[date] ), ALLSELECTED () )&lt;/DIV&gt;&lt;DIV&gt;VAR _end = CALCULATE ( MAX ( 'fact_table'[Prev Month End Date] ), REMOVEFILTERS () )&lt;/DIV&gt;&lt;DIV&gt;var _start = CALCULATE ( MAX ( 'fact_table'[Prev Month Start Date] ), REMOVEFILTERS () )&lt;/DIV&gt;&lt;DIV&gt;VAR __Days = 7&lt;/DIV&gt;&lt;DIV&gt;VAR __Result =&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; IF (&amp;nbsp;__Isdatesfiltered,&amp;nbsp;SELECTEDMEASURE (),&amp;nbsp;CALCULATE (&amp;nbsp;SELECTEDMEASURE (),&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; KEEPFILTERS (&amp;nbsp;FILTER (&amp;nbsp;ALL ( 'dim_date' ),&amp;nbsp;'dim_date'[date] &amp;gt;= _start&amp;nbsp;&amp;amp;&amp;amp; 'dim_date'[date] &amp;lt;= _end&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ) )))&lt;/DIV&gt;&lt;DIV&gt;RETURN&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; __Result&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;// mtd&lt;/DIV&gt;&lt;DIV&gt;VAR __Isdatesfiltered =&amp;nbsp;CALCULATE ( ISFILTERED ( 'dim_date'[date] ), ALLSELECTED () )&lt;/DIV&gt;&lt;DIV&gt;VAR _todaymonthstart =&amp;nbsp;EOMONTH ( TODAY (), -1 ) + 1&lt;/DIV&gt;&lt;DIV&gt;VAR _todaymonthend =&amp;nbsp; CALCULATE (&amp;nbsp;MAX ( 'fact_table'[Date] ),&amp;nbsp;REMOVEFILTERS ())&lt;BR /&gt;VAR __Result =&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CALCULATE (&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;selectedmeasure(),&amp;nbsp;KEEPFILTERS(&amp;nbsp;FILTER (&amp;nbsp;ALL ('al_pres_dimad dim_date' ),&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'al_pres_dimad dim_date'[date] &amp;gt;= _todaymonthstart&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;&amp;amp; 'al_pres_dimad dim_date'[date] &amp;lt;= _todaymonthend - 1&amp;nbsp; )))&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;RETURN&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; __Result&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;// fy to date&lt;/DIV&gt;&lt;DIV&gt;VAR _start =&amp;nbsp;MAXX (&amp;nbsp;ALLSELECTED ( 'fact_table' ),&amp;nbsp;'fact_table'[FY Start Date]&amp;nbsp; )&lt;/DIV&gt;&lt;DIV&gt;VAR _end =&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; CALCULATE (&amp;nbsp;MAX ( 'fact_table'[Date] ),&amp;nbsp;REMOVEFILTERS ()&amp;nbsp;)&lt;/DIV&gt;&lt;DIV&gt;VAR __Result =&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; CALCULATE (&amp;nbsp;SELECTEDMEASURE (),&amp;nbsp;KEEPFILTERS (&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FILTER (&amp;nbsp;ALL ( 'dim_date' ),&amp;nbsp;'dim_date'[date] &amp;gt;= _start&amp;nbsp;&amp;nbsp;&amp;amp;&amp;amp; 'dim_date'[date] &amp;lt;= _end - 1&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&amp;nbsp; )&amp;nbsp; )&lt;/DIV&gt;&lt;DIV&gt;RETURN&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; __Result&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;BR /&gt;and this is the measure I created for Slicer B&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;//for Primary vs Month on Month calculations&lt;BR /&gt;var _last7DaysMoM = CALCULATE([Actual],DATEADD('dim_date'[date],-1,MONTH))&lt;BR /&gt;var _mtdMoM = CALCULATE([Actual], DATEADD('dim_date'[date],-1,MONTH))&lt;BR /&gt;var _lastMonthMoM = CALCULATE([Actual], PARALLELPERIOD('dim_date'[date],-1,MONTH))&lt;BR /&gt;var _ytdMoM = CALCULATE( [Actual], DATEADD('dim_date'[date],-1,MONTH))&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;//for Primary vs Year on Year calculations&lt;BR /&gt;var _last7DaysYoY = CALCULATE([Actual], DATEADD('dim_date'[date],-1,YEAR))&lt;BR /&gt;var _mtdYoY = CALCULATE( [Actual ],DATEADD('dim_date'[date],-1,YEAR))&lt;BR /&gt;var _lastMonthYoY = CALCULATE( [Actual],PARALLELPERIOD('dim_date'[date],-1,YEAR))&lt;BR /&gt;var _ytdYoY = CALCULATE([Actual], DATEADD('dim_date'[date],-1,YEAR))&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;For the Slicer B, I was able to make it work for the Last 7 Days and FYTD and got the desired results. However, I am having issues with MTD and Last Month since it's returning blank values for the Slicer B.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;My follow up question is, should I adjust the calculation I have in Slicer A for the MTD and Last Month? or should I change the DATEADD dax function I used for the Slicer B?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 17 Oct 2023 02:09:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-month-previous-year-using-calculation-groups/m-p/3480014#M133010</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-17T02:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get previous month / previous year using calculation groups</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-month-previous-year-using-calculation-groups/m-p/3481168#M133089</link>
      <description>&lt;P&gt;I would go with Field Parameters and independent measures.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 13:35:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-month-previous-year-using-calculation-groups/m-p/3481168#M133089</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-10-17T13:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Get previous month / previous year using calculation groups</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-month-previous-year-using-calculation-groups/m-p/3488806#M133518</link>
      <description>&lt;P&gt;Thank you! This works for my report.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Oct 2023 02:00:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-previous-month-previous-year-using-calculation-groups/m-p/3488806#M133518</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-21T02:00:24Z</dc:date>
    </item>
  </channel>
</rss>

