<?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: Show current and last year calculated column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-current-and-last-year-calculated-column/m-p/3403039#M128547</link>
    <description>&lt;P&gt;To replicate the logic in DAX, you'll want to create a calculated column. Before diving into the DAX formula, it's important to understand that DAX has slightly different functions and syntax than what you'd find in Crystal Reports formulas.&lt;/P&gt;
&lt;P&gt;Here's how you might translate your logic into DAX:&lt;/P&gt;
&lt;P&gt;Year Group = &lt;BR /&gt;VAR CurrentYear = YEAR(TODAY())&lt;BR /&gt;VAR LastYear = CurrentYear - 1&lt;BR /&gt;RETURN&lt;BR /&gt;IF (&lt;BR /&gt;Rentals[Year] = CurrentYear, &lt;BR /&gt;CurrentYear,&lt;BR /&gt;IF (&lt;BR /&gt;Rentals[Input Date] &amp;lt; DATE(LastYear, 1, 1) &amp;amp;&amp;amp; Rentals[Year] = LastYear, &lt;BR /&gt;LastYear, &lt;BR /&gt;0&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;In the above DAX formula:&lt;/P&gt;
&lt;P&gt;I'm using the TODAY() function to get the current date.&lt;BR /&gt;The YEAR() function extracts the year portion of a date.&lt;BR /&gt;The DATE() function creates a date from year, month, and day components.&lt;BR /&gt;You'd add this calculated column to your Rentals table (or an equivalent table in your Power BI model).&lt;/P&gt;
&lt;P&gt;After creating the column, you can then use the "Year Group" column to create your desired visualizations in Power BI.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Aug 2023 21:03:30 GMT</pubDate>
    <dc:creator>technolog</dc:creator>
    <dc:date>2023-08-28T21:03:30Z</dc:date>
    <item>
      <title>Show current and last year calculated column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-current-and-last-year-calculated-column/m-p/115135#M197</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In a crystal report i have the following where i have a Year Group based on the below in order to see the revenue based on a user's input date on the reservation system and revenuew to come in based on customers reservation date. How can i replecated this with dax?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if {Rentals.Year} = Year (CurrentDate) then YEAR(CURRENTDATE)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;else&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if {Rentals.Input Date} &amp;lt; {@DateLastYear} and {Rentals.Year} = Year (CurrentDate)-1 then Year (CurrentDate)-1 &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;else&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;**@DateLastYear is Year(CurrentDate)-1&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 10:45:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-current-and-last-year-calculated-column/m-p/115135#M197</guid>
      <dc:creator>asl10</dc:creator>
      <dc:date>2017-01-18T10:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: Show current and last year calculated column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-current-and-last-year-calculated-column/m-p/3403039#M128547</link>
      <description>&lt;P&gt;To replicate the logic in DAX, you'll want to create a calculated column. Before diving into the DAX formula, it's important to understand that DAX has slightly different functions and syntax than what you'd find in Crystal Reports formulas.&lt;/P&gt;
&lt;P&gt;Here's how you might translate your logic into DAX:&lt;/P&gt;
&lt;P&gt;Year Group = &lt;BR /&gt;VAR CurrentYear = YEAR(TODAY())&lt;BR /&gt;VAR LastYear = CurrentYear - 1&lt;BR /&gt;RETURN&lt;BR /&gt;IF (&lt;BR /&gt;Rentals[Year] = CurrentYear, &lt;BR /&gt;CurrentYear,&lt;BR /&gt;IF (&lt;BR /&gt;Rentals[Input Date] &amp;lt; DATE(LastYear, 1, 1) &amp;amp;&amp;amp; Rentals[Year] = LastYear, &lt;BR /&gt;LastYear, &lt;BR /&gt;0&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;In the above DAX formula:&lt;/P&gt;
&lt;P&gt;I'm using the TODAY() function to get the current date.&lt;BR /&gt;The YEAR() function extracts the year portion of a date.&lt;BR /&gt;The DATE() function creates a date from year, month, and day components.&lt;BR /&gt;You'd add this calculated column to your Rentals table (or an equivalent table in your Power BI model).&lt;/P&gt;
&lt;P&gt;After creating the column, you can then use the "Year Group" column to create your desired visualizations in Power BI.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 21:03:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-current-and-last-year-calculated-column/m-p/3403039#M128547</guid>
      <dc:creator>technolog</dc:creator>
      <dc:date>2023-08-28T21:03:30Z</dc:date>
    </item>
  </channel>
</rss>

