<?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: YTD Flag using DAX in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2414830#M63752</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355449" data-lia-user-login="apatwal" class="lia-mention lia-mention-user"&gt;apatwal&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Here is a sample file&amp;nbsp;&lt;A href="https://www.dropbox.com/t/pgHYjhGndQZwRb4N" target="_blank"&gt;https://www.dropbox.com/t/pgHYjhGndQZwRb4N&lt;/A&gt;&lt;BR /&gt;I suppose by "Current Date" you mean today. Also I did not fully understand why the year number is hard codded. Are you using card visuals?&lt;BR /&gt;Anyway, the aproach should be the same. Craete a disconnected selection table&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;SELECTION = SELECTCOLUMNS ( { "YTD Flag", "Full Year Flag" }, "Flag Selection", [Value] )&lt;/LI-CODE&gt;&lt;P&gt;The basic two measure&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;Total Revenue = SUM ( Data[Revenue] )&lt;/LI-CODE&gt;&lt;LI-CODE lang="cpp"&gt;YTD Revenue = 
VAR CurrentYear = 
    YEAR ( MAX ( 'Date'[Date] ) )
VAR Result =
    IF ( 
        [Total Revenue] &amp;gt; 0,
        CALCULATE (
            [Total Revenue],
            REMOVEFILTERS ('Date' ),
            Data[Invoice Date] &amp;lt;= TODAY ( ),
            Data[Invoice Date] &amp;gt;= DATE ( CurrentYear, 1, 1 )
        )
    )
RETURN
    Result&lt;/LI-CODE&gt;&lt;P&gt;And the measure to use in visual&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;Selected Revenue = 
IF (
    SELECTEDVALUE ( SELECTION[Flag Selection] ) = "YTD Flag", [YTD Revenue],
    [Total Revenue]
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Mar 2022 11:12:24 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2022-03-24T11:12:24Z</dc:date>
    <item>
      <title>YTD Flag using DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2414317#M63712</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a requirement to add a flag in my report.&lt;/P&gt;&lt;P&gt;Flag has two values YTD Flag and Full Year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When YTD Flag is selected,&amp;nbsp;&lt;SPAN&gt;it will show the values in the table in terms of Jan 1 of the respective year to the current date, while Full Year flag shows the data from 1st jan to 31st dec of respective year.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have my data from year 2020, 2021 and 2022 and want to display the revenue for each year on different columns in table. To display each year revenue on different columns I am using below dax&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;2020 Revenue = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;data[Revenue]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;data&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;YEAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;data[Invoice Date]&lt;/SPAN&gt;&lt;SPAN&gt;) = &lt;/SPAN&gt;&lt;SPAN&gt;2020&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Same for other years by changing year in above dax.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Need help in creating Flag meachanism.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Appreciate your help!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 29 Mar 2022 12:03:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2414317#M63712</guid>
      <dc:creator>apatwal</dc:creator>
      <dc:date>2022-03-29T12:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: YTD Flag using DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2414345#M63714</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355449" data-lia-user-login="apatwal" class="lia-mention lia-mention-user"&gt;apatwal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You allways come up with nice ideas. Will try to play around with it once I return back to office. Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 07:59:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2414345#M63714</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-24T07:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: YTD Flag using DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2414386#M63716</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355449" data-lia-user-login="apatwal" class="lia-mention lia-mention-user"&gt;apatwal&lt;/a&gt; , You can create a flag like this in date table &lt;/P&gt;
&lt;P&gt;if( format([Date], "MMDD") &amp;lt; = format(today(), "MMDD") ,1,0)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Prefer date table in case of time intelligence&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 08:19:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2414386#M63716</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-03-24T08:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: YTD Flag using DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2414830#M63752</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355449" data-lia-user-login="apatwal" class="lia-mention lia-mention-user"&gt;apatwal&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Here is a sample file&amp;nbsp;&lt;A href="https://www.dropbox.com/t/pgHYjhGndQZwRb4N" target="_blank"&gt;https://www.dropbox.com/t/pgHYjhGndQZwRb4N&lt;/A&gt;&lt;BR /&gt;I suppose by "Current Date" you mean today. Also I did not fully understand why the year number is hard codded. Are you using card visuals?&lt;BR /&gt;Anyway, the aproach should be the same. Craete a disconnected selection table&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;SELECTION = SELECTCOLUMNS ( { "YTD Flag", "Full Year Flag" }, "Flag Selection", [Value] )&lt;/LI-CODE&gt;&lt;P&gt;The basic two measure&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;Total Revenue = SUM ( Data[Revenue] )&lt;/LI-CODE&gt;&lt;LI-CODE lang="cpp"&gt;YTD Revenue = 
VAR CurrentYear = 
    YEAR ( MAX ( 'Date'[Date] ) )
VAR Result =
    IF ( 
        [Total Revenue] &amp;gt; 0,
        CALCULATE (
            [Total Revenue],
            REMOVEFILTERS ('Date' ),
            Data[Invoice Date] &amp;lt;= TODAY ( ),
            Data[Invoice Date] &amp;gt;= DATE ( CurrentYear, 1, 1 )
        )
    )
RETURN
    Result&lt;/LI-CODE&gt;&lt;P&gt;And the measure to use in visual&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;Selected Revenue = 
IF (
    SELECTEDVALUE ( SELECTION[Flag Selection] ) = "YTD Flag", [YTD Revenue],
    [Total Revenue]
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 11:12:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2414830#M63752</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-24T11:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: YTD Flag using DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2414958#M63761</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply!&lt;/P&gt;&lt;P&gt;I understand your approach. I am building matrix visual and want to show data for 2022 and 2021 revenue only in matrix visual (or table visual) with change in revenue (2022 rev - 2021 rev) and revenue change% columns based on location.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While in chart, I want to display revenue for each years (2020, 2021 and 2022) something like year over year.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 12:03:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2414958#M63761</guid>
      <dc:creator>apatwal</dc:creator>
      <dc:date>2022-03-24T12:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: YTD Flag using DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2415058#M63774</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355449" data-lia-user-login="apatwal" class="lia-mention lia-mention-user"&gt;apatwal&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;You can filter the report to include the years you want that is not an issue.&amp;nbsp;&lt;BR /&gt;How do you calculate the %Revenue Change? Location is no problem as well, you can add as slicer. Can you share ascreenshot of the expected report?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 12:42:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2415058#M63774</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-24T12:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: YTD Flag using DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2415094#M63775</link>
      <description>&lt;P&gt;In theory, you can unify both to DATESYTD() by manipulating the evaluation context for it. Here's the trick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 13:05:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2415094#M63775</guid>
      <dc:creator>CNENFRNL</dc:creator>
      <dc:date>2022-03-24T13:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: YTD Flag using DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2415127#M63779</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is snapshot for matrix visual (ignore Margin% as of now).&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, Location can be filter through slicer.&lt;/P&gt;&lt;P&gt;Revenue change % = (2022 rev - 2021 rev)/2021 rev&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While in chart Revenue should be visible as below which should gradually grow as we have subsequent months data:&lt;/P&gt;&lt;P&gt;Blue : 2022 Revenue&lt;/P&gt;&lt;P&gt;Gray : 2021 Revenue&lt;/P&gt;&lt;P&gt;Orange : 2020 Revenue&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 13:15:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2415127#M63779</guid>
      <dc:creator>apatwal</dc:creator>
      <dc:date>2022-03-24T13:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: YTD Flag using DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2415195#M63781</link>
      <description>&lt;P&gt;Omit it, this is for fun only; an imporved measure which can produce correct date at the end of Feburary (assume today is 28 Feb, 2022).&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 13:40:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2415195#M63781</guid>
      <dc:creator>CNENFRNL</dc:creator>
      <dc:date>2022-03-24T13:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: YTD Flag using DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2420332#M64081</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you have the chance to look into my last reply?&lt;/P&gt;&lt;P&gt;Let me know if you need any further information.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 04:56:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2420332#M64081</guid>
      <dc:creator>apatwal</dc:creator>
      <dc:date>2022-03-28T04:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: YTD Flag using DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2420416#M64087</link>
      <description>&lt;P&gt;I'm Sorry&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355449" data-lia-user-login="apatwal" class="lia-mention lia-mention-user"&gt;apatwal&lt;/a&gt;&amp;nbsp; Just saw your reply. I'll have a look at your reply soon and get back to you.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 05:44:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2420416#M64087</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-28T05:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: YTD Flag using DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2428843#M64599</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355449" data-lia-user-login="apatwal" class="lia-mention lia-mention-user"&gt;apatwal&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Final solution is as follows&lt;BR /&gt;Create a disconnected selection table&lt;/P&gt;&lt;LI-CODE lang="php"&gt;SELECTION = SELECTCOLUMNS ( { "YTD Flag", "Full Year Flag" }, "Flag Selection", [Value] )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Example measure&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Invoice revenue 2020 = SUM ( 'Main table'[Invoice Revenue] )&lt;/LI-CODE&gt;&lt;P&gt;The YTD of a certain year (for example 2020 ) of the above measure would be&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Invoice revenue 2020 YTD = 
VAR CurrentYear = 2020
VAR TodayDay = DAY ( TODAY () )
VAR TodayMonth = MONTH ( TODAY () )
VAR Result =
    IF (
        SUM ( 'Main table'[Invoice Revenue] ) &amp;gt; 0,
        CALCULATE (
            SUM ( 'Main table'[Invoice Revenue] ),
            FILTER (
                'Main table',
                'Main table'[Invoice Date] &amp;lt;= DATE ( CurrentYear, TodayMonth, TodayDay )
                    &amp;amp;&amp;amp; 'Main table'[Invoice Date] &amp;gt;= DATE ( CurrentYear, 1, 1 )
            )
        )
    )
RETURN 
    Result&lt;/LI-CODE&gt;&lt;P&gt;The measure to be used in the visual&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Selected revenue 2020 = 
IF (
    SELECTEDVALUE ( Selection[Flag Selection] ) = "YTD flag",
    [Invoice revenue 2020 YTD],
    [Invoice revenue 2020]
)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 31 Mar 2022 07:50:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-Flag-using-DAX/m-p/2428843#M64599</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-31T07:50:42Z</dc:date>
    </item>
  </channel>
</rss>

