<?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: Last Year dynamically calculated in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-Year-dynamically-calculated/m-p/1034593#M13705</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please share the sample data and expected output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have calculated values where the column changes dynamically i.e shows Total Cost incase Filter in not selected and shows Total Sales if the filter is selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Date Slicer is from the Calendar Table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Filter = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var __mini = CALCULATE ( MIN ( Dates[Date] ), ALLSELECTED ( Dates[Date] ) )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var __maxi = CALCULATE ( MAX ( Dates[Date] ), ALLSELECTED ( Dates[Date] ) )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var __mind = MIN(Dates[Date])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var __maxd = MAX(Dates[Date])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var __datediffmin = DATEDIFF(__mind,__mini,DAY)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var __datediffmax = DATEDIFF(__maxd,__maxi,DAY)&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 ((__datediffmin = 0 || __datediffmax = 0),[Total Sales],[Total Costs])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;You can replace the Total Sales and Total Cost with the YTD and YTD from today.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;img /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Let me know if this is what you are looking for.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Harsh Nathani&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Sun, 19 Apr 2020 10:48:21 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-04-19T10:48:21Z</dc:date>
    <item>
      <title>Last Year dynamically calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-Year-dynamically-calculated/m-p/1034490#M13702</link>
      <description>&lt;P&gt;Hi there, I'm facing with the following problem.&lt;/P&gt;&lt;P&gt;I need to create an Last Year measure.&lt;/P&gt;&lt;P&gt;then I created a calculated group like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;v_dim_time and v_fact_sales are related to 1:n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var DayToCompare = today()&lt;BR /&gt;var DateLastYear = EDATE(DayToCompare;-12)&lt;BR /&gt;return&lt;BR /&gt;calculate(&lt;BR /&gt;SELECTEDMEASURE ();&lt;BR /&gt;year(v_DIM_TIME[CALENDAR_DATE_SQL]) = Year(DateLastYear);&lt;BR /&gt;v_DIM_TIME[CALENDAR_DATE_SQL] &amp;lt;= dateLastYear&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is how can I to made the formula dynamical, saying for example that ytd will be evaluated at today - 365 if no other selection are made by time slicer otherview keeping the value selected ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Apr 2020 07:46:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-Year-dynamically-calculated/m-p/1034490#M13702</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-19T07:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Last Year dynamically calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-Year-dynamically-calculated/m-p/1034499#M13703</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Using&amp;nbsp;&lt;A title="Click here" href="https://docs.microsoft.com/en-us/dax/isfiltered-function-dax" target="_blank" rel="noopener"&gt;ISFILTERED()&amp;nbsp;&lt;/A&gt; function you can identify if the column is filtered or not. Based on that, you can switch your logic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution!&lt;BR /&gt;Appreciate with a kudos &lt;/STRONG&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Apr 2020 08:21:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-Year-dynamically-calculated/m-p/1034499#M13703</guid>
      <dc:creator>nandukrishnavs</dc:creator>
      <dc:date>2020-04-19T08:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Last Year dynamically calculated</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-Year-dynamically-calculated/m-p/1034593#M13705</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please share the sample data and expected output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have calculated values where the column changes dynamically i.e shows Total Cost incase Filter in not selected and shows Total Sales if the filter is selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Date Slicer is from the Calendar Table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Filter = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var __mini = CALCULATE ( MIN ( Dates[Date] ), ALLSELECTED ( Dates[Date] ) )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var __maxi = CALCULATE ( MAX ( Dates[Date] ), ALLSELECTED ( Dates[Date] ) )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var __mind = MIN(Dates[Date])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var __maxd = MAX(Dates[Date])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var __datediffmin = DATEDIFF(__mind,__mini,DAY)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var __datediffmax = DATEDIFF(__maxd,__maxi,DAY)&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 ((__datediffmin = 0 || __datediffmax = 0),[Total Sales],[Total Costs])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;You can replace the Total Sales and Total Cost with the YTD and YTD from today.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;img /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Let me know if this is what you are looking for.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Harsh Nathani&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 19 Apr 2020 10:48:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-Year-dynamically-calculated/m-p/1034593#M13705</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-19T10:48:21Z</dc:date>
    </item>
  </channel>
</rss>

