<?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: Conditional formatting based on formula - previousyear calculation in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conditional-formatting-based-on-formula-previousyear-calculation/m-p/3701558#M143960</link>
    <description>&lt;P&gt;I've managed to figure it out!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I needed to use SAMPERIODLASTYEAR function and use it with separate Calendar Year - also in the visualization I changed the Year field to the one from the Calendar table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Icon Revenue = 
VAR _val =
 CALCULATE ( SUM ( Sales[Revenue] ) ) 
 -
CALCULATE (
    SUM ( Sales[Revenue] ),
    SAMEPERIODLASTYEAR( ( 'Calendar'[Date] )
))
        
RETURN
    IF (
        ISBLANK ( _val ) || SELECTEDVALUE('Sales'[Time.Fiscal Year Name]) = "21/22",
        BLANK (),  -- If previous year's data is not available or it's for 21/22 fiscal year, return blank to turn off conditional formatting
        SWITCH (
            TRUE (),
            _val &amp;lt; 0, -1, 
            _val = 0, 0,
            _val &amp;gt; 0, 1
        )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works great :).&lt;/P&gt;</description>
    <pubDate>Thu, 15 Feb 2024 14:37:59 GMT</pubDate>
    <dc:creator>Maieev</dc:creator>
    <dc:date>2024-02-15T14:37:59Z</dc:date>
    <item>
      <title>Conditional formatting based on formula - previousyear calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conditional-formatting-based-on-formula-previousyear-calculation/m-p/3700830#M143923</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table - Sales, where I have Actual ASP and Revenue columns. I wrote a formula to be able to show conditional formatting - icons based on the difference between years. It works for Revenue but doesn't for Actual ASP. They are in the same table, with the same dates. The only difference is that in column Revenue there are no blanks, and in Actual ASP blanks are possible and they are there.&lt;BR /&gt;&lt;BR /&gt;Measure that works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Icon Revenue = 
VAR _val =
 CALCULATE ( SUM ( Sales[Revenue] ) ) 
 -
 CALCULATE ( SUM ( Sales[Revenue] ),
        PREVIOUSYEAR ( Sales[Date] ), ALL(Sales) )
        
RETURN
    IF (
        ISBLANK ( _val ) || SELECTEDVALUE('Sales'[Time.Fiscal Year Name]) = "21/22",
        BLANK (),  -- If previous year's data is not available or it's for 21/22 fiscal year, return blank to turn off conditional formatting
        SWITCH (
            TRUE (),
            _val &amp;lt; 0, -1, 
            _val = 0, 0,
            _val &amp;gt; 0, 1
        )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;And that doesn't work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Icon ASP = 
VAR _val =
    CALCULATE ( SUM ( Sales[Actual ASP] ) ) 
    -
    CALCULATE (
        SUM ( Sales[Actual ASP] ),
           PREVIOUSYEAR ( Sales[Date] ), ALL(Sales) )
        
RETURN
    IF (
        ISBLANK ( _val ) || SELECTEDVALUE('Sales'[Time.Fiscal Year Name]) = "21/22",
        BLANK (),  -- If previous year's data is not available or it's for 21/22 fiscal year, return blank to turn off conditional formatting
        SWITCH (
            TRUE (),
            _val &amp;lt; 0, -1, 
            _val = 0, 0,
            _val &amp;gt; 0, 1
        )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried to connect that to calendar table and take date from there but still no result. I broke down formula and wanted to check that PreviousYear calculation but it doesn't show results in the table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PreviousYearASP = 
CALCULATE (
    SUM ( Sales[Actual ASP] ),
    PREVIOUSYEAR ( Sales[Date] )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;As you can see there are values. I don't know why one measure works and the other just with column name changed not. Their format in the table is exactly the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help with some ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 09:29:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conditional-formatting-based-on-formula-previousyear-calculation/m-p/3700830#M143923</guid>
      <dc:creator>Maieev</dc:creator>
      <dc:date>2024-02-15T09:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional formatting based on formula - previousyear calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conditional-formatting-based-on-formula-previousyear-calculation/m-p/3701558#M143960</link>
      <description>&lt;P&gt;I've managed to figure it out!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I needed to use SAMPERIODLASTYEAR function and use it with separate Calendar Year - also in the visualization I changed the Year field to the one from the Calendar table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Icon Revenue = 
VAR _val =
 CALCULATE ( SUM ( Sales[Revenue] ) ) 
 -
CALCULATE (
    SUM ( Sales[Revenue] ),
    SAMEPERIODLASTYEAR( ( 'Calendar'[Date] )
))
        
RETURN
    IF (
        ISBLANK ( _val ) || SELECTEDVALUE('Sales'[Time.Fiscal Year Name]) = "21/22",
        BLANK (),  -- If previous year's data is not available or it's for 21/22 fiscal year, return blank to turn off conditional formatting
        SWITCH (
            TRUE (),
            _val &amp;lt; 0, -1, 
            _val = 0, 0,
            _val &amp;gt; 0, 1
        )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works great :).&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 14:37:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Conditional-formatting-based-on-formula-previousyear-calculation/m-p/3701558#M143960</guid>
      <dc:creator>Maieev</dc:creator>
      <dc:date>2024-02-15T14:37:59Z</dc:date>
    </item>
  </channel>
</rss>

