<?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 Custom Column for Relative Date Range Measures in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Column-for-Relative-Date-Range-Measures/m-p/3769040#M147188</link>
    <description>&lt;P&gt;What I am trying to do is to:&lt;BR /&gt;&lt;BR /&gt;1) Calculate difference in unit sales between two date ranges&lt;BR /&gt;2) If units sold in date range 1 is less than units sold in date range 2, then a custom column is used to call this out with "Leakage".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works if I use static range as below:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dax for Product A&amp;nbsp; 2022 is:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I wanted to do a similar analysis but using relative date range instead of statc date range.&amp;nbsp; The table looks like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Now, the units for the 2022 total uses this dax:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;And, the units for 2023 total uses this dax:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The custom column that shows "Leakage" is thus:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, there there should be "Leakage" labled for West region but it's blank.&amp;nbsp; I assume my dax in custom column above doesn't work with relative date ranges.&amp;nbsp; So, is there a way to get the Leakage custom column to show "Leakage" for Wetern Region in the table with relative date ranges?&lt;BR /&gt;&lt;BR /&gt;Sample file is below:&lt;BR /&gt;&lt;A href="https://www.dropbox.com/scl/fi/jwfigbghq3gx705q7wywz/YOY-Test.pbix?rlkey=fpo5j8lpuuic496xwgcaveblc&amp;amp;dl=0" target="_self"&gt;Sample&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update:&lt;BR /&gt;&lt;BR /&gt;Adding what is ultimately what I am trying to achieve which is a filter that filters for Regions that have Decrease YOY Units in Product A and Increase YOY units in Product B which indicates possible conversion from Product A to B but using relative instead of static date DAX:&lt;BR /&gt;&lt;BR /&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;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Mar 2024 21:02:32 GMT</pubDate>
    <dc:creator>edtm</dc:creator>
    <dc:date>2024-03-19T21:02:32Z</dc:date>
    <item>
      <title>Custom Column for Relative Date Range Measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Column-for-Relative-Date-Range-Measures/m-p/3769040#M147188</link>
      <description>&lt;P&gt;What I am trying to do is to:&lt;BR /&gt;&lt;BR /&gt;1) Calculate difference in unit sales between two date ranges&lt;BR /&gt;2) If units sold in date range 1 is less than units sold in date range 2, then a custom column is used to call this out with "Leakage".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works if I use static range as below:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dax for Product A&amp;nbsp; 2022 is:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I wanted to do a similar analysis but using relative date range instead of statc date range.&amp;nbsp; The table looks like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Now, the units for the 2022 total uses this dax:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;And, the units for 2023 total uses this dax:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The custom column that shows "Leakage" is thus:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, there there should be "Leakage" labled for West region but it's blank.&amp;nbsp; I assume my dax in custom column above doesn't work with relative date ranges.&amp;nbsp; So, is there a way to get the Leakage custom column to show "Leakage" for Wetern Region in the table with relative date ranges?&lt;BR /&gt;&lt;BR /&gt;Sample file is below:&lt;BR /&gt;&lt;A href="https://www.dropbox.com/scl/fi/jwfigbghq3gx705q7wywz/YOY-Test.pbix?rlkey=fpo5j8lpuuic496xwgcaveblc&amp;amp;dl=0" target="_self"&gt;Sample&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update:&lt;BR /&gt;&lt;BR /&gt;Adding what is ultimately what I am trying to achieve which is a filter that filters for Regions that have Decrease YOY Units in Product A and Increase YOY units in Product B which indicates possible conversion from Product A to B but using relative instead of static date DAX:&lt;BR /&gt;&lt;BR /&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;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 21:02:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Column-for-Relative-Date-Range-Measures/m-p/3769040#M147188</guid>
      <dc:creator>edtm</dc:creator>
      <dc:date>2024-03-19T21:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Column for Relative Date Range Measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Column-for-Relative-Date-Range-Measures/m-p/3769812#M147233</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="570511" data-lia-user-login="edtm" class="lia-mention lia-mention-user"&gt;edtm&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Based on your description, I can understand that you mean you want to dynamically determine the range and calculate the difference of the dates while making a comment on the positive and negative values. Unfortunately, the pbix file you provided cannot be opened. Please provide your complete data in table or excel format so that we can help you faster. Please hide sensitive information in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Albert He&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 02:24:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Column-for-Relative-Date-Range-Measures/m-p/3769812#M147233</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-18T02:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Column for Relative Date Range Measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Column-for-Relative-Date-Range-Measures/m-p/3770034#M147239</link>
      <description>&lt;P&gt;Thank you for looking into my question.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just tested downloading the sample file and was able to open it.&amp;nbsp; At first I was like... wat's this? but then there's the download button:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I am sure this didn't get past you but not sure why else the file can't be accessed.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here's the base table sample data I put together in excel.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.dropbox.com/scl/fi/fqbcwozlos4zm8e8yh4k1/YOY-Test.xlsx?rlkey=w24yz2hf7eqx589d02u9hsvze&amp;amp;dl=0" target="_self"&gt;Excel Sample&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;However, it might not be useful as without the PBIX file you can't see how I am I using it.&lt;BR /&gt;&lt;BR /&gt;(But, I guess you could come up with your own method.)&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 05:05:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Column-for-Relative-Date-Range-Measures/m-p/3770034#M147239</guid>
      <dc:creator>edtm</dc:creator>
      <dc:date>2024-03-18T05:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Column for Relative Date Range Measures</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Column-for-Relative-Date-Range-Measures/m-p/3796187#M148374</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="570511" data-lia-user-login="edtm" class="lia-mention lia-mention-user"&gt;edtm&lt;/a&gt;&amp;nbsp;，&lt;BR /&gt;Here some steps that I want to share, you can check them if they suitable for your requirement.&lt;BR /&gt;Here is my test data:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Create 2 calendar tables&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Calendar 1 = VALUES('Table'[Year])
Calendar 2 = VALUES('Table'[Year])&lt;/LI-CODE&gt;
&lt;P&gt;Create measures&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Selected by Calendar 1 = 
CALCULATE(
    MAX('Table'[Value]),
    FILTER(
        'Table',
        'Table'[Year] = SELECTEDVALUE('Calendar 1'[Year])
    )
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Selected by Calendar 2 = 
CALCULATE(
    MAX('Table'[Value]),
    FILTER(
        'Table',
        'Table'[Year] = SELECTEDVALUE('Calendar 2'[Year])
    )
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Value1 vs value 2 = [Selected by Calendar 1] - [Selected by Calendar 2]&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Leakage or not = 
IF(
    [Value1 vs value 2] &amp;lt; 0,
    "Leakage",
    "increase"
)&lt;/LI-CODE&gt;
&lt;P&gt;Use the values of the two calendar tables as separate slicers&lt;BR /&gt;Final output&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Albert He&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2024 09:37:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Column-for-Relative-Date-Range-Measures/m-p/3796187#M148374</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-03-28T09:37:29Z</dc:date>
    </item>
  </channel>
</rss>

