<?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: Using measures as filters on visuals in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-measures-as-filters-on-visuals/m-p/2408394#M63321</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , if you need only rolling 13 month data &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Rolling 13 Sales = &lt;BR /&gt;var _max = maxx(allselcted(date),date[date]) // or today() &lt;BR /&gt;var _min = date(year(_max), month(_max)-13,1)&lt;BR /&gt;return &lt;BR /&gt;CALCULATE(SUM(Sales[Sales Amount]),filter(date, date[date] &amp;lt;=_max &amp;amp;&amp;amp; date[date] &amp;gt;=_min))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rolling 13 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-13,MONTH)) &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you select 1 month and want to have a trend for 13 months then you need an independent date table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//Date1 is independent Date table, Date is joined with Table &lt;BR /&gt;new measure =&lt;BR /&gt;var _max = maxx(allselected(Date1),Date1[Date])&lt;BR /&gt;var _min = eomonth(_max, -12) +1 &lt;BR /&gt;return &lt;BR /&gt;calculate( sum(Table[Value]), filter('Date', 'Date'[Date] &amp;gt;=_min &amp;amp;&amp;amp; 'Date'[Date] &amp;lt;=_max))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need of an Independent Date Table:&lt;A href="https://www.youtube.com/watch?v=44fGGmg9fHI" target="_blank"&gt;https://www.youtube.com/watch?v=44fGGmg9fHI&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Mar 2022 06:05:23 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2022-03-22T06:05:23Z</dc:date>
    <item>
      <title>Using measures as filters on visuals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-measures-as-filters-on-visuals/m-p/2407195#M63261</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm creating a report where a user can filter the data by year and month. Within this report, I would like to include a visual that displays trends, including data from the month/year selected and the 12 months before that. I have created measures that calculate the first and last date of the trend figure;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Fdate = &lt;/SPAN&gt;&lt;SPAN&gt;EDATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;date&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;selectedvalue&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'[DateYear]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;selectedvalue&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'[DateMonth]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;),-&lt;/SPAN&gt;&lt;SPAN&gt;12&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;// First date&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Ldate = &lt;/SPAN&gt;&lt;SPAN&gt;date&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;selectedvalue&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'[DateYear]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;selectedvalue&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'[DateMonth]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;)+&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;)-&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt; &lt;SPAN&gt;// Last date&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;However, I don't seem to be able to use these measures as a filter in visuals.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Does anyone have a solution to this? Or any suggestions how I can create a L13M trend visual with the period depening on filtered dates?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Eva&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 21 Mar 2022 16:39:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-measures-as-filters-on-visuals/m-p/2407195#M63261</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-21T16:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using measures as filters on visuals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-measures-as-filters-on-visuals/m-p/2408394#M63321</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , if you need only rolling 13 month data &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Rolling 13 Sales = &lt;BR /&gt;var _max = maxx(allselcted(date),date[date]) // or today() &lt;BR /&gt;var _min = date(year(_max), month(_max)-13,1)&lt;BR /&gt;return &lt;BR /&gt;CALCULATE(SUM(Sales[Sales Amount]),filter(date, date[date] &amp;lt;=_max &amp;amp;&amp;amp; date[date] &amp;gt;=_min))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rolling 13 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-13,MONTH)) &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you select 1 month and want to have a trend for 13 months then you need an independent date table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//Date1 is independent Date table, Date is joined with Table &lt;BR /&gt;new measure =&lt;BR /&gt;var _max = maxx(allselected(Date1),Date1[Date])&lt;BR /&gt;var _min = eomonth(_max, -12) +1 &lt;BR /&gt;return &lt;BR /&gt;calculate( sum(Table[Value]), filter('Date', 'Date'[Date] &amp;gt;=_min &amp;amp;&amp;amp; 'Date'[Date] &amp;lt;=_max))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need of an Independent Date Table:&lt;A href="https://www.youtube.com/watch?v=44fGGmg9fHI" target="_blank"&gt;https://www.youtube.com/watch?v=44fGGmg9fHI&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 06:05:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-measures-as-filters-on-visuals/m-p/2408394#M63321</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-03-22T06:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using measures as filters on visuals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-measures-as-filters-on-visuals/m-p/2409341#M63379</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;In general you can follow this rule&lt;/P&gt;&lt;LI-CODE lang="php"&gt;New Measure =
VAR Fdate =
    EDATE (
        DATE ( SELECTEDVALUE ( 'Date'[DateYear], 0 ), SELECTEDVALUE ( 'Date'[DateMonth], 0 ), 1 ),
        -12
    )
VAR Ldate =
    DATE ( SELECTEDVALUE ( 'Date'[DateYear], 0 ), SELECTEDVALUE ( 'Date'[DateMonth], 0 ) + 1, 1 ) - 1
VAR Result =
    CALCULATE (
        [Old Measure],
        REMOVEFILTERS ( 'Date' ),
        'Date'[Date] &amp;gt;= Fdate,
        'Date'[Date] &amp;lt;= Ldate
    )
RETURN
    Result&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 22 Mar 2022 11:57:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-measures-as-filters-on-visuals/m-p/2409341#M63379</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-22T11:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using measures as filters on visuals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-measures-as-filters-on-visuals/m-p/2409344#M63380</link>
      <description>&lt;P&gt;Hi Amit,&lt;BR /&gt;&lt;BR /&gt;Thank you so much for the reply - I have tried it and watched your video and is very informative, and the solution works. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I however still have a problem, the L13M trend visual is part of a report where we're going deep dive into one month. I therefore want the user to select a month in a Slicer, see some data regarding only that month, and then see the L13M trend visual as well (with the last month being the selected month). Is there any way to do this, without having the user select the month &amp;amp; year in a slicer for the monthly overview, and having to select it again in a seperate slicer for the L13M visual? Can I do this with a single slicer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;Eva&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 11:58:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-measures-as-filters-on-visuals/m-p/2409344#M63380</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-22T11:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using measures as filters on visuals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-measures-as-filters-on-visuals/m-p/2409505#M63399</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;Some good news and some bad news. You can't use measures as slicers/filters.&lt;/P&gt;&lt;P&gt;But you can create a calculation for say sales, e.g.&lt;/P&gt;&lt;P&gt;Sales = SUM(SalesTable[Revenue])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if you have data for 13 months or more, to get your trend you can use relative Date Slicer use Date field from your Date Table. Here's what is looks like and you can apply it to whichever visuals you like. Have a Date Table connected to your fact table makes life so much easier and yo can use all the built in time intelligence measures Power BI offers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To Make a Date Table (Basic). Let's say for 2021 thru 2022&lt;/P&gt;&lt;P&gt;Go to Modeling.&lt;/P&gt;&lt;P&gt;Choose New Table. We can name it Dates.&lt;/P&gt;&lt;P&gt;Dates = CALENDAR(DATE(2021,1,1), DATE(2022,12,31))&lt;/P&gt;&lt;P&gt;You can add columns for Year &amp;amp; Month and Year-Month , etc&lt;/P&gt;&lt;P&gt;YEAR = YEAR(Dates[Date])&lt;/P&gt;&lt;P&gt;Month No. = MONTH(Dates[Date])&lt;/P&gt;&lt;P&gt;Year &amp;amp; Month No. = FORMAT(Dates[Date], "YYYYMM")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then under Table tools at the top slect Mark as Date Table. Choose Date field and click OK.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now you can connect this Date Table to a table of facts that usually have a date and some tye of transaction that goes with it, like sales, a visit, any factual type of data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could go on but want to see if this is helpful first. See relative slicer below using Date field from new Date Table. You can set it to 1st of the month, etc. Lot's of options.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 12:54:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-measures-as-filters-on-visuals/m-p/2409505#M63399</guid>
      <dc:creator>Whitewater100</dc:creator>
      <dc:date>2022-03-22T12:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Using measures as filters on visuals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-measures-as-filters-on-visuals/m-p/2409535#M63405</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , if you select 1 month and try get more than one month then you have to use independent date table &lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 13:01:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-measures-as-filters-on-visuals/m-p/2409535#M63405</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-03-22T13:01:43Z</dc:date>
    </item>
  </channel>
</rss>

