<?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 Determine next step based on latest information in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Determine-next-step-based-on-latest-information/m-p/2844352#M90964</link>
    <description>&lt;P&gt;Hi all!&lt;/P&gt;
&lt;P&gt;I have a table that shows me the current state per order:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="20%"&gt;Order Number&lt;/TD&gt;
&lt;TD width="20%"&gt;Article&lt;/TD&gt;
&lt;TD width="20%"&gt;State 1&lt;/TD&gt;
&lt;TD width="20%"&gt;State 2&lt;/TD&gt;
&lt;TD width="20%"&gt;Quantity&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="20%"&gt;5556&lt;/TD&gt;
&lt;TD width="20%"&gt;Bike 1&lt;/TD&gt;
&lt;TD width="20%"&gt;60&lt;/TD&gt;
&lt;TD width="20%"&gt;1&lt;/TD&gt;
&lt;TD width="20%"&gt;500&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="20%"&gt;5557&lt;/TD&gt;
&lt;TD width="20%"&gt;Bike 2&lt;/TD&gt;
&lt;TD width="20%"&gt;50&lt;/TD&gt;
&lt;TD width="20%"&gt;3&lt;/TD&gt;
&lt;TD width="20%"&gt;600&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;State 1: This columns shows the process step sequence&lt;/LI&gt;
&lt;LI&gt;State 2: This columns contains values 1,2 or 3.
&lt;UL&gt;
&lt;LI&gt;1: Started&lt;/LI&gt;
&lt;LI&gt;2: In Progress&lt;/LI&gt;
&lt;LI&gt;3: Finished&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Then I have a second table that shows me for each article the necessary steps:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Article&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;State 1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Description&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Bike 1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;20&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Assembly&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Bike 1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;50&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Drill&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Bike 1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;60&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Mount&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="30px"&gt;Bike 1&lt;/TD&gt;
&lt;TD height="30px"&gt;20&lt;/TD&gt;
&lt;TD height="30px"&gt;Assembly&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="30px"&gt;Bike 1&lt;/TD&gt;
&lt;TD height="30px"&gt;30&lt;/TD&gt;
&lt;TD height="30px"&gt;Drill&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I would like to calculate the next step (calculated column) in the first table based on this conditions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If State 2 = 1 or 2, then take Description of table 2&lt;/LI&gt;
&lt;LI&gt;If State 2 = 3, then take the Description if table 2 for the next state 1.&lt;BR /&gt;
&lt;UL&gt;
&lt;LI&gt;If the last state was reached, then display "Finished".&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;How would you do that in DAX?&lt;/P&gt;</description>
    <pubDate>Sun, 16 Oct 2022 08:39:11 GMT</pubDate>
    <dc:creator>joshua1990</dc:creator>
    <dc:date>2022-10-16T08:39:11Z</dc:date>
    <item>
      <title>Determine next step based on latest information</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Determine-next-step-based-on-latest-information/m-p/2844352#M90964</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;
&lt;P&gt;I have a table that shows me the current state per order:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="20%"&gt;Order Number&lt;/TD&gt;
&lt;TD width="20%"&gt;Article&lt;/TD&gt;
&lt;TD width="20%"&gt;State 1&lt;/TD&gt;
&lt;TD width="20%"&gt;State 2&lt;/TD&gt;
&lt;TD width="20%"&gt;Quantity&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="20%"&gt;5556&lt;/TD&gt;
&lt;TD width="20%"&gt;Bike 1&lt;/TD&gt;
&lt;TD width="20%"&gt;60&lt;/TD&gt;
&lt;TD width="20%"&gt;1&lt;/TD&gt;
&lt;TD width="20%"&gt;500&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="20%"&gt;5557&lt;/TD&gt;
&lt;TD width="20%"&gt;Bike 2&lt;/TD&gt;
&lt;TD width="20%"&gt;50&lt;/TD&gt;
&lt;TD width="20%"&gt;3&lt;/TD&gt;
&lt;TD width="20%"&gt;600&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;State 1: This columns shows the process step sequence&lt;/LI&gt;
&lt;LI&gt;State 2: This columns contains values 1,2 or 3.
&lt;UL&gt;
&lt;LI&gt;1: Started&lt;/LI&gt;
&lt;LI&gt;2: In Progress&lt;/LI&gt;
&lt;LI&gt;3: Finished&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Then I have a second table that shows me for each article the necessary steps:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Article&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;State 1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Description&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Bike 1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;20&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Assembly&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Bike 1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;50&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Drill&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Bike 1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;60&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="30px"&gt;Mount&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="30px"&gt;Bike 1&lt;/TD&gt;
&lt;TD height="30px"&gt;20&lt;/TD&gt;
&lt;TD height="30px"&gt;Assembly&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="30px"&gt;Bike 1&lt;/TD&gt;
&lt;TD height="30px"&gt;30&lt;/TD&gt;
&lt;TD height="30px"&gt;Drill&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I would like to calculate the next step (calculated column) in the first table based on this conditions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If State 2 = 1 or 2, then take Description of table 2&lt;/LI&gt;
&lt;LI&gt;If State 2 = 3, then take the Description if table 2 for the next state 1.&lt;BR /&gt;
&lt;UL&gt;
&lt;LI&gt;If the last state was reached, then display "Finished".&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;How would you do that in DAX?&lt;/P&gt;</description>
      <pubDate>Sun, 16 Oct 2022 08:39:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Determine-next-step-based-on-latest-information/m-p/2844352#M90964</guid>
      <dc:creator>joshua1990</dc:creator>
      <dc:date>2022-10-16T08:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Determine next step based on latest information</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Determine-next-step-based-on-latest-information/m-p/2845724#M91058</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="92006" data-lia-user-login="joshua1990" class="lia-mention lia-mention-user"&gt;joshua1990&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You can create a calculated column as below in &lt;STRONG&gt;table 1&lt;/STRONG&gt; to achieve the first condition:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If State 2 = 1 or 2, then take Description of table 2&lt;/LI&gt;
&lt;/UL&gt;
&lt;LI-CODE lang="markup"&gt;Description = 
CALCULATE (
    MAX ( 'Table 2'[Description] ),
    FILTER (
        'Table 2',
        'Table 2'[Article] = 'Table 1'[Article]
            &amp;amp;&amp;amp; 'Table 1'[State 2] IN { 1, 2 }
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;And for the second condition, I'm not clear about "&lt;SPAN&gt;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;table 2 for the next state 1&lt;/STRONG&gt;&lt;/EM&gt;&lt;/SPAN&gt;". What's the meaning of that?&amp;nbsp; Could you please explain more on it base on the current data of table 1 and table 2? Thank you.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If State 2 = 3, then take the Description if table 2 for the next state 1.&lt;BR /&gt;
&lt;UL&gt;
&lt;LI&gt;If the last state was reached, then display "Finished".&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 07:04:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Determine-next-step-based-on-latest-information/m-p/2845724#M91058</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-17T07:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: Determine next step based on latest information</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Determine-next-step-based-on-latest-information/m-p/2846152#M91081</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Anonymous&lt;/a&gt;&amp;nbsp;'s solution should help you to solve your issue. Another interesting approach to this is to use OFFSET function described here: &lt;A href="https://data-marc.com/2022/09/21/how-offset-in-dax-will-make-your-life-easier/" target="_blank"&gt;How OFFSET in DAX will make your life easier – Data – Marc (data-marc.com)&lt;/A&gt;&lt;BR /&gt;I am not sure if that would be the optimal solution in the end. So here is another option to consider:&lt;BR /&gt;&lt;BR /&gt;Is there a particular need to use a calculated column? You could for example create this kind of measure: &lt;BR /&gt;var _state1 = MAX(Table1[state1]) &lt;BR /&gt;var _state2 = MAX(Table1[state2])&lt;BR /&gt;return&lt;BR /&gt;&lt;BR /&gt;IF(_state2=3,"Finished",&lt;BR /&gt;CALCULATE(MAX(Table2[description]),ALL(Table2[state1]),Table2[state1]=_state1)&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;If you need an additional logic for state2 = 2 then use SWITCH + TRUE:&lt;BR /&gt;&lt;BR /&gt;var _state1 =&amp;nbsp;MAX(table1[state1])&lt;BR /&gt;var _state2 = MAX(table1[state2])&lt;BR /&gt;var _nextstate1 =&amp;nbsp;CALCULATE(MIN(Table2[state1]),ALL(Table2[state1]),Table2[state1]&amp;gt;_state1)&lt;BR /&gt;return&lt;BR /&gt;SWITCH(TRUE(),&lt;BR /&gt;_state2 = 1,&amp;nbsp;CALCULATE(MAX(Table2[description]),ALL(Table2[state1]),Table2[state1]=_state1),&lt;BR /&gt;_state2 = 2,CALCULATE(MAX(Table2[description]),ALL(Table2[state1]),Table2[state1]=_nextstate1),&lt;BR /&gt;_state2 = 3, "Finished")&lt;BR /&gt;&lt;BR /&gt;I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!&lt;BR /&gt;&lt;BR /&gt;My LinkedIn: &lt;A href="https://www.linkedin.com/in/n%C3%A4ttiahov-00001/" target="_blank"&gt;https://www.linkedin.com/in/n%C3%A4ttiahov-00001/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 09:54:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Determine-next-step-based-on-latest-information/m-p/2846152#M91081</guid>
      <dc:creator>ValtteriN</dc:creator>
      <dc:date>2022-10-17T09:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: Determine next step based on latest information</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Determine-next-step-based-on-latest-information/m-p/2854921#M91721</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="92006" data-lia-user-login="joshua1990" class="lia-mention lia-mention-user"&gt;joshua1990&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Whether your problem has been resolved? If yes, could you please mark the helpful post as &lt;STRONG&gt;&lt;SPAN&gt;Answered&lt;/SPAN&gt;&lt;/STRONG&gt;? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 05:44:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Determine-next-step-based-on-latest-information/m-p/2854921#M91721</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-21T05:44:47Z</dc:date>
    </item>
  </channel>
</rss>

