<?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: Extract a Single Value from a Column with Duplicates, Filtered by Another Column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-a-Single-Value-from-a-Column-with-Duplicates-Filtered-by/m-p/1061291#M14770</link>
    <description>&lt;P&gt;Thank you very much! I appreciate the help.&lt;/P&gt;</description>
    <pubDate>Fri, 01 May 2020 15:49:07 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-05-01T15:49:07Z</dc:date>
    <item>
      <title>Extract a Single Value from a Column with Duplicates, Filtered by Another Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-a-Single-Value-from-a-Column-with-Duplicates-Filtered-by/m-p/1060093#M14704</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wrestling with what I think should be a very simple DAX measure problem, but nothing I have tried yet has worked. Here's the situation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with colulmns [Academic Year] and [Current Year Flag]. There are duplicate values in both of these columns, since they are part of a table that inludes all classes offered at an institution, and details about those classes. Because multiple classes are offered in a year, there are duplicate year values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, my goal is to calculate a measure (we'll call it Metric Previous Year) based on a particular column's values from a previous year, i.e., current academic year - 1. Someone before me (using an earlier data warehouse source with different architecture and different field names) approached it like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Metric Previous Year =&lt;/P&gt;&lt;P&gt;CALCULATE (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Metric],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILTER (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ALL ( 'Term Dim' ),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Term Dim'[Academic Year Numeric]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = MAX ( 'Term Dim'[Academic Year Numeric] ) - 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp; 'Term Dim'[Quarter] IN VALUES ( 'Term Dim'[Quarter] )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In other words, they used MAX to find the largest value in [Academic Year Numeric] and subtracted 1 to find the previous year. But in the data warehous source I am working with, there are some [Academic Year] values for years in the future, meaning that MAX will return a higher number than the current year, and if I subtract 1 I will not get last year.&lt;BR /&gt;&lt;BR /&gt;What I need to do is extract a single value for [Academic Year] where [Current Year Flag] = True, then use this year to subtract and find the previous year. As a beginner, it seems like I should be able to do this with FILTER() and DISTINCT(), but something confusing about the context or something else I don't understand has prevented me from getting this working. Any suggestions are greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 22:11:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-a-Single-Value-from-a-Column-with-Duplicates-Filtered-by/m-p/1060093#M14704</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-30T22:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a Single Value from a Column with Duplicates, Filtered by Another Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-a-Single-Value-from-a-Column-with-Duplicates-Filtered-by/m-p/1060140#M14708</link>
      <description>&lt;P&gt;First, sample data would be tremendously helpful:&amp;nbsp;Please see this post regarding How to Get Your Question Answered Quickly: &lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, perhaps:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CALCULATE (

    [Metric],

    FILTER (

        ALL ( 'Term Dim' ),

        'Term Dim'[Academic Year Numeric]

            = MAXX ( FILTER('Term Dim',[Current Year Flag] = 1,[Academic Year Numeric] ) - 1

            &amp;amp;&amp;amp; 'Term Dim'[Quarter] IN VALUES ( 'Term Dim'[Quarter] )

    )

)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 30 Apr 2020 22:39:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-a-Single-Value-from-a-Column-with-Duplicates-Filtered-by/m-p/1060140#M14708</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-04-30T22:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a Single Value from a Column with Duplicates, Filtered by Another Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-a-Single-Value-from-a-Column-with-Duplicates-Filtered-by/m-p/1060280#M14723</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You're absolutely right - I should have provided sample data. It would have made it easier for people to answer my question, and it would have helped me catch an important omission I didn't notice in my original question. The metric in question (which I called [Metric]) is actually a calculated measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Metric =
DIVIDE ( SUM ( [Net Revenue] ), SUM ( [Revenue] ) )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the updated field and table names&amp;nbsp;&lt;SPAN&gt;(from the newer schema I'm working off of, with a table name of 'dw B2 Class View'), your proposed solution would - I think - look like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Metric Prior Year = 
CALCULATE (
    [Metric],
    FILTER (
        ALL ( 'dw B2 Class View' ),
        'dw B2 Class View'[Academic Year]
            = MAXX ( FILTER('dw B2 Class View', [Current Year Flag] = 1,[Academic Year] ) - 1
            &amp;amp;&amp;amp; 'dw B2 Class View'[Academic Year] IN VALUES ( 'dw B2 Class View'[Academic Year] )
    )
)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The MAXX function seems like the right thing to use, but I run into a "too many arguments were passed into the FILTER function" problem. And I think that is actually the root of the problem - trying to figure out how to filter the table based on one column while returning a single related value from a different column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again so much for your help, and sorry for not getting my question right the first time.&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;The sample data (from the newer schema I'm working off of, with a table name of 'dw B2 Class View') is as follows:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Revenue&lt;/TD&gt;&lt;TD&gt;Net Revenue&lt;/TD&gt;&lt;TD&gt;Academic Year&lt;/TD&gt;&lt;TD&gt;Current Year Flag&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;80&lt;/TD&gt;&lt;TD&gt;2015&lt;/TD&gt;&lt;TD&gt;FALSE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;250&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;2015&lt;/TD&gt;&lt;TD&gt;FALSE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;TD&gt;-20&lt;/TD&gt;&lt;TD&gt;2015&lt;/TD&gt;&lt;TD&gt;FALSE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;535&lt;/TD&gt;&lt;TD&gt;520&lt;/TD&gt;&lt;TD&gt;2016&lt;/TD&gt;&lt;TD&gt;FALSE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;542&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;2016&lt;/TD&gt;&lt;TD&gt;FALSE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;886&lt;/TD&gt;&lt;TD&gt;-70&lt;/TD&gt;&lt;TD&gt;2017&lt;/TD&gt;&lt;TD&gt;FALSE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;546&lt;/TD&gt;&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t;TD&gt;500&lt;/TD&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;TRUE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;573&lt;/TD&gt;&lt;TD&gt;72&lt;/TD&gt;&lt;TD&gt;2021&lt;/TD&gt;&lt;TD&gt;FALSE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;331&lt;/TD&gt;&lt;TD&gt;-20&lt;/TD&gt;&lt;TD&gt;2021&lt;/TD&gt;&lt;TD&gt;FALSE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;-80&lt;/TD&gt;&lt;TD&gt;2022&lt;/TD&gt;&lt;TD&gt;FALSE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;347&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;2022&lt;/TD&gt;&lt;TD&gt;FALSE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;798&lt;/TD&gt;&lt;TD&gt;700&lt;/TD&gt;&lt;TD&gt;2022&lt;/TD&gt;&lt;TD&gt;FALSE&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 01 May 2020 02:10:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-a-Single-Value-from-a-Column-with-Duplicates-Filtered-by/m-p/1060280#M14723</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-01T02:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a Single Value from a Column with Duplicates, Filtered by Another Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-a-Single-Value-from-a-Column-with-Duplicates-Filtered-by/m-p/1060348#M14726</link>
      <description>&lt;P&gt;Looks like I left out a paren or something, try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Metric Prior Year = 
CALCULATE (
    [Metric],
    FILTER (
        ALL ( 'dw B2 Class View' ),
        'dw B2 Class View'[Academic Year]
            = MAXX 
               ( 
                 FILTER(
                   'dw B2 Class View', 
                   [Current Year Flag] = 1 &amp;amp;&amp;amp; 
                   'dw B2 Class View'[Academic Year] IN DISTINCT ( 'dw B2 Class View'[Academic Year] )
                 ), //end second FILTER
                 [Academic Year]
              ) //end MAXX
              - 1
    ) // end first FILTER
) // end CALCULATE&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also replaced VALUES with DISTINCT. I just wrote a blog article on this topic, but that wasn't because of you.&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Community-Blog/Soapbox-Series-Adding-No-VALUE-S/ba-p/1059818" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Soapbox-Series-Adding-No-VALUE-S/ba-p/1059818&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 02:56:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-a-Single-Value-from-a-Column-with-Duplicates-Filtered-by/m-p/1060348#M14726</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-05-01T02:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract a Single Value from a Column with Duplicates, Filtered by Another Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-a-Single-Value-from-a-Column-with-Duplicates-Filtered-by/m-p/1061291#M14770</link>
      <description>&lt;P&gt;Thank you very much! I appreciate the help.&lt;/P&gt;</description>
      <pubDate>Fri, 01 May 2020 15:49:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Extract-a-Single-Value-from-a-Column-with-Duplicates-Filtered-by/m-p/1061291#M14770</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-01T15:49:07Z</dc:date>
    </item>
  </channel>
</rss>

