<?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: Show the last research in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-the-last-research/m-p/3270667#M121208</link>
    <description>&lt;P&gt;Is your date table marked as a date table? Is it linked to the date in the responses table ?&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jun 2023 13:57:12 GMT</pubDate>
    <dc:creator>johnt75</dc:creator>
    <dc:date>2023-06-06T13:57:12Z</dc:date>
    <item>
      <title>Show the last research</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-the-last-research/m-p/3269419#M121115</link>
      <description>&lt;P&gt;Hi guys, need your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a sheet with some NPS researchs and the date for each research. I uploaded this at power bi and made a relation with calendar table.&lt;BR /&gt;&lt;BR /&gt;Now what I need is show the last NPS research when I filter month and year.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 3 researches in this dates&lt;/P&gt;&lt;P&gt;1 NPS: 11/04/2022&lt;/P&gt;&lt;P&gt;2 NPS: 20/11/2022&lt;/P&gt;&lt;P&gt;3 NPS: 15/05/2023&lt;/P&gt;&lt;P&gt;- if I select year 2022 and month 4 I want the result for the first NPS;&lt;/P&gt;&lt;P&gt;- if I select year 2022 and month 5 I still want the result for the first NPS, because it's the last until this date;&lt;/P&gt;&lt;P&gt;- if I select year 2022 and month 12 I want the result for the seconde NPS;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, what I need it's always the very last research until the date that I filtered.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is example base, we have promoters, detractor and passives. Link:&amp;nbsp;&lt;A href="https://drive.google.com/drive/folders/1A8sRH_YUFI6OpIK96d9vNeQUyFnO10cn?usp=sharing" target="_blank"&gt;https://drive.google.com/drive/folders/1A8sRH_YUFI6OpIK96d9vNeQUyFnO10cn?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;NPS is defined by:&lt;/P&gt;&lt;P&gt;NPS = (sum promoters)/(total responses) - (sum detractors)/(total responses)&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 00:17:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-the-last-research/m-p/3269419#M121115</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-06T00:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Show the last research</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-the-last-research/m-p/3270062#M121155</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;NPS =
VAR CurrentDate =
    MAX ( 'Date'[Date] )
VAR PrevDate =
    CALCULATE ( MAX ( Responses[Date] ), 'Date'[Date] &amp;lt;= CurrentDate )
VAR TotalResponses =
    CALCULATE ( COUNTROWS ( Responses ), 'Date'[Date] = PrevDate )
VAR Promoters =
    CALCULATE (
        SUM ( Responses[Score] ),
        TREATAS (
            { ( PrevDate, "Promoter" ) },
            'Date'[Date],
            Responses[classification]
        )
    )
VAR Detractors =
    CALCULATE (
        SUM ( Responses[Score] ),
        TREATAS (
            { ( PrevDate, "Detractor" ) },
            'Date'[Date],
            Responses[classification]
        )
    )
VAR Result =
    DIVIDE ( Promoters, TotalResponses ) - DIVIDE ( Detractors, TotalResponses )
RETURN
    Result
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 06 Jun 2023 09:16:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-the-last-research/m-p/3270062#M121155</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-06-06T09:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: Show the last research</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-the-last-research/m-p/3270652#M121206</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;! Thank you for the answer!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does not work :(!&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The result is "Blank". I think we should consider the filters in currentDate variable!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 13:49:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-the-last-research/m-p/3270652#M121206</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-06T13:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Show the last research</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-the-last-research/m-p/3270667#M121208</link>
      <description>&lt;P&gt;Is your date table marked as a date table? Is it linked to the date in the responses table ?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 13:57:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-the-last-research/m-p/3270667#M121208</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-06-06T13:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Show the last research</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-the-last-research/m-p/3271023#M121240</link>
      <description>&lt;P&gt;Yes, it is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;and that is my measure&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    VAR data_atual = MAX('dim_calendário'[Data])
    VAR data_nps = CALCULATE(MAX(fato_nps[Data]), 'dim_calendário'[Data] &amp;lt;= data_atual)
    VAR total_respostas = CALCULATE(COUNTROWS(fato_nps), 'dim_calendário'[Data] = data_nps)
    VAR Promotores = 
                    CALCULATE(SUM(fato_nps[Nota]), 
                                TREATAS({(data_nps, "Promotores")}, 
                                        'dim_calendário'[Data],
                                        fato_nps[Classificação]
                                        )
                            )
    VAR Detratores = CALCULATE(SUM(fato_nps[Nota]), 
                                TREATAS({(data_nps, "Promotores")}, 
                                        'dim_calendário'[Data],
                                        fato_nps[Classificação]
                                        )
                            )
    VAR Resultado = DIVIDE(Promotores, total_respostas) - DIVIDE(Detratores, total_respostas)
RETURN
    Resultado&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 16:48:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-the-last-research/m-p/3271023#M121240</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-06T16:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Show the last research</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-the-last-research/m-p/3272169#M121319</link>
      <description>&lt;P&gt;To see where the problem lies I would edit the measure to return the different variables which are declared.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 08:29:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-the-last-research/m-p/3272169#M121319</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-06-07T08:29:32Z</dc:date>
    </item>
  </channel>
</rss>

