<?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: How to get value of KPI from last date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-get-value-of-KPI-from-last-date/m-p/2774320#M86523</link>
    <description>&lt;P&gt;Thank You, I read a lot but DAX i still hard and not intuitive. I would like to have KPI not from 1 month back but from all dates till the date from a filter context in table.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 18:24:17 GMT</pubDate>
    <dc:creator>Marcin82</dc:creator>
    <dc:date>2022-09-16T18:24:17Z</dc:date>
    <item>
      <title>How to get value of KPI from last date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-get-value-of-KPI-from-last-date/m-p/2767552#M86012</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess it is a noob question but i have already spent several hours without a solution, high level of frustration,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have KPIs names in rows. Months in colums. The both create filter context as far as I know. I would like to fill all months with KPI values &lt;U&gt;from the last month&lt;/U&gt; (let assume that last is december). I tried ALL () etc. but I cant find solution and an answer why it works like that. I created measure like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;kpi value for last month =&amp;nbsp;&lt;BR /&gt;var lastmonth = lastdate(date[date])&lt;/P&gt;&lt;P&gt;return&lt;/P&gt;&lt;P&gt;CALCULATE(SUM([kpi value]), FILTER(ALL(dates)), date[date] = [lastmonth]).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I thought that it will fill all table with KPI value from december, despite the date filter context provided by colums(there are months)&lt;BR /&gt;It does not work. Colums with months still filter the measure. I dont understand why it happens as there is ALL(dates) included.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 14:03:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-get-value-of-KPI-from-last-date/m-p/2767552#M86012</guid>
      <dc:creator>Marcin82</dc:creator>
      <dc:date>2022-09-14T14:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to get value of KPI from last date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-get-value-of-KPI-from-last-date/m-p/2769526#M86156</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="397018" data-lia-user-login="Marcin82" class="lia-mention lia-mention-user"&gt;Marcin82&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try:&lt;/P&gt;
&lt;P&gt;kpi value for last month =&amp;nbsp;&lt;BR /&gt;var lastmonth = &lt;STRONG&gt;month(calculate(lastdate(dates[date]), all(dates)))&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;return&lt;/P&gt;
&lt;P&gt;CALCULATE(SUM([kpi value]), FILTER(ALL(dates)), &lt;STRONG&gt;month(dates[date])&lt;/STRONG&gt; = [lastmonth]).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Community Support Team _ chenwu zhu&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 09:52:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-get-value-of-KPI-from-last-date/m-p/2769526#M86156</guid>
      <dc:creator>v-chenwuz-msft</dc:creator>
      <dc:date>2022-09-15T09:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to get value of KPI from last date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-get-value-of-KPI-from-last-date/m-p/2769737#M86175</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="397018" data-lia-user-login="Marcin82" class="lia-mention lia-mention-user"&gt;Marcin82&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your formula does not work because you use&amp;nbsp;&lt;SPAN&gt;v&lt;STRONG&gt;ar lastmonth = lastdate(date[date])&lt;/STRONG&gt; and this line just grabs the last date &lt;FONT color="#FF0000"&gt;&lt;EM&gt;visible in the current context&lt;/EM&gt;&lt;/FONT&gt;. Please, before you write anything in DAX, check out what a particular function does. Without this knowledge you won't be getting what you want. If you want to grab a value of a measure that is calculated for a period removed from the current one by 1 month, you have to use this formula:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;[KPI 1M-] = // KPI one month back
    calculate(
        [KPI],
        // dateadd moves the current set of dates
        // one month back.
        dateadd(Dates[Date], -1, MONTH),
        // If your calendar, Dates, is marked as
        // as a Date Table in the model, this last
        // line is not necessary (but does no harm).
        removefilters( Dates )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 08:57:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-get-value-of-KPI-from-last-date/m-p/2769737#M86175</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-09-15T08:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to get value of KPI from last date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-get-value-of-KPI-from-last-date/m-p/2774320#M86523</link>
      <description>&lt;P&gt;Thank You, I read a lot but DAX i still hard and not intuitive. I would like to have KPI not from 1 month back but from all dates till the date from a filter context in table.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 18:24:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-get-value-of-KPI-from-last-date/m-p/2774320#M86523</guid>
      <dc:creator>Marcin82</dc:creator>
      <dc:date>2022-09-16T18:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get value of KPI from last date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-get-value-of-KPI-from-last-date/m-p/2774431#M86533</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;// KPI calculated for the whole period
// from the beginning of time in the calendar
// until the last date visible in the current context.
[KPI (until now)] =
var LastVisibleDate = max( Dates[Date] )
var Output = 
    calculate(
        [KPI],
        Dates[Date] &amp;lt;= LastVisibleDate,
        // If your calendar, Dates, is marked as
        // as a Date Table in the model, this last
        // line is not necessary (but does no harm).
        removefilters( Dates )
    )
return
    Output&lt;/LI-CODE&gt;
&lt;P&gt;but maybe you want this:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;// KPI for the period from the beginning of time
// until the last date of the previous month.
// Previous month is calculated as the month BEFORE
// the first date in the current context. This is
// how the function PREVIOUSMONTH works.
[KPI (until now)] =
var LastDatePrevMonth = max( previousmonth( Dates[Date] ) )
var Output = 
    calculate(
        [KPI],
        Dates[Date] &amp;lt;= LastDatePrevMonth,
        // If your calendar, Dates, is marked as
        // as a Date Table in the model, this last
        // line is not necessary (but does no harm).
        removefilters( Dates )
    )
return
    Output&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 19:22:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-get-value-of-KPI-from-last-date/m-p/2774431#M86533</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-09-16T19:22:08Z</dc:date>
    </item>
  </channel>
</rss>

