<?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: Getting the maximum value for each order in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3022623#M102913</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I managed to solve it through af combination of the suggestions posted in the thread.&lt;/P&gt;&lt;P&gt;Thanks to everyone for inputs!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution for the time of controls was:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;FirstControl =
    MINX (
        TOPN (
            1, 
            'QualityControl', 
            'QualityControl'[CheckedDateTime], 
            DESC 
        ), 
        'QualityControl'[CheckedDateTime] 
    )

SecondControl = 
    MINX (
        TOPN (
            2, 
            'QualityControl', 
            'QualityControl'[CheckedDateTime], 
            DESC 
        ), 
        'QualityControl'[CheckedDateTime] 
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I actually needed the five latest times of control I just increased the TOPN value for each measure.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Jan 2023 08:45:51 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-01-16T08:45:51Z</dc:date>
    <item>
      <title>Getting the maximum value for each order</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3011128#M102079</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Quite often I run into an issue regarding my relationships between tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case I have information on production orders, processes and quality in three different tables. They are related as shown below:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a table containing the following columns (parenthesis is the data origin table)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Workcenter (Tasks)&lt;/P&gt;&lt;P&gt;Production order (Production order)&lt;/P&gt;&lt;P&gt;Due date (Production order)&lt;/P&gt;&lt;P&gt;Time of first QC (Quality Control)&lt;/P&gt;&lt;P&gt;Time of second QC (Quality Control)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My issue is that when I try to get the times for QC I get the absolute max for every workcenter and production order.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to create a workaround using DAX or is it necessary to re-create the tables as a query or view directly in SQL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 12:16:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3011128#M102079</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-01-10T12:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the maximum value for each order</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3011149#M102081</link>
      <description>&lt;P&gt;You could create a measure like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;First QC =
SELECTCOLUMNS (
    INDEX (
        1,
        'Quality Control',
        ORDERBY ( 'Quality Control'[Checked datetime], ASC ),
        PARTITIONBY ( 'Quality Control'[Production Order No] )
    ),
    "@val", 'Quality Control'[Checked datetime]
)
&lt;/LI-CODE&gt;
&lt;P&gt;and for the second time just change the first argument to INDEX to 2 instead of 1. Make sure that your table visual is using the production order number column from the production order table and it should work.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 12:36:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3011149#M102081</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-01-10T12:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the maximum value for each order</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3011157#M102082</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;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks for your response!&lt;BR /&gt;I'm unable to use the INDEX function. I think it's due to the DirectQuery connection.&lt;BR /&gt;I have the same issue sometimes with the CALCULATE function.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 12:42:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3011157#M102082</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-01-10T12:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the maximum value for each order</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3011267#M102089</link>
      <description>&lt;P&gt;Are you running the December 2022 version of Power BI Desktop? If not, try updating to the latest version. The INDEX function was only introduced in November or December I think.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 13:50:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3011267#M102089</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-01-10T13:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the maximum value for each order</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3016392#M102445</link>
      <description>&lt;P&gt;Sorry for my late response.&lt;BR /&gt;It took some time to get Power BI Desktop updated as I'm not allowed to do it myself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried to use your suggestion but get the error:&lt;/P&gt;&lt;P&gt;"INDEX Relation paramter may have duplicate rows. That is not allowed."&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 09:52:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3016392#M102445</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-01-12T09:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the maximum value for each order</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3016429#M102448</link>
      <description>&lt;P&gt;For the first QC date you could simply use MIN('Quality Control'[Checked datetime]), for the 2nd you can try&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Second QC =
VAR Top2 =
    TOPN ( 2, 'Quality Control', 'Quality Control'[Checked datetime], ASC )
RETURN
    MINX ( Top2, 'Quality Control'[Checked datetime] )
&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 12 Jan 2023 10:06:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3016429#M102448</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-01-12T10:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the maximum value for each order</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3016758#M102468</link>
      <description>&lt;P&gt;I still have issues.&lt;/P&gt;&lt;P&gt;Unfortunately I'm not able to share the data as a DirectQuery connection, but I've made some sample data in Excel. Both Excel and PBIX files are attached.&lt;/P&gt;&lt;P&gt;I've tried to create both of the measures you've suggested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/drive/folders/1vQGG9PGobKcCIm8IxlvhXgwwM7RPyT1z?usp=sharing" target="_blank"&gt;https://drive.google.com/drive/folders/1vQGG9PGobKcCIm8IxlvhXgwwM7RPyT1z?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once again, thank you very much for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 13:06:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3016758#M102468</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-01-12T13:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the maximum value for each order</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3016830#M102472</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this what you're looking for?&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 13:36:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3016830#M102472</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-01-12T13:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the maximum value for each order</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3016878#M102475</link>
      <description>&lt;P&gt;It needs to be MAXX, not MINX&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SecondControl = 
VAR Top2 =
    TOPN ( 2, 'QualityControl', 'QualityControl'[Checkeddatetime], ASC )
RETURN
    MAXX ( Top2, 'QualityControl'[Checkeddatetime] )&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 12 Jan 2023 13:56:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3016878#M102475</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-01-12T13:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the maximum value for each order</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3022623#M102913</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I managed to solve it through af combination of the suggestions posted in the thread.&lt;/P&gt;&lt;P&gt;Thanks to everyone for inputs!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution for the time of controls was:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;FirstControl =
    MINX (
        TOPN (
            1, 
            'QualityControl', 
            'QualityControl'[CheckedDateTime], 
            DESC 
        ), 
        'QualityControl'[CheckedDateTime] 
    )

SecondControl = 
    MINX (
        TOPN (
            2, 
            'QualityControl', 
            'QualityControl'[CheckedDateTime], 
            DESC 
        ), 
        'QualityControl'[CheckedDateTime] 
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I actually needed the five latest times of control I just increased the TOPN value for each measure.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 08:45:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-maximum-value-for-each-order/m-p/3022623#M102913</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-01-16T08:45:51Z</dc:date>
    </item>
  </channel>
</rss>

