<?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 Complex IF Statement in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1970393#M43260</link>
    <description>&lt;P&gt;I have a table with a machine column and a minutes column. There are 9 different machines and the table is recording the events in which a machine was stopped and how long it was stopped for (the minutes column).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, for just 4 different machines I need to return a value base on the minutes column. But the values returned depend on both the machine and the minutes. For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Machine 1 - If minutes between 0-3, I need to return 0. If minutes between 3-8, I need to return 1. If minutes between 8-13, I need to return 2. If minutes in between 13-18, I need to return 3. If minutes between 18-23, I need to return 4. If minutes between 23-28, I need to return 5. If minutes are above 28, I need to return 6.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Machine 2 - If minutes between 0-2, return 0.&amp;nbsp;If minutes between 2-7, return 1.&amp;nbsp;If minutes between 7-12, return 2.&amp;nbsp;If minutes between 12-17, return 3.&amp;nbsp;If minutes between 17-22, return 4.&amp;nbsp;If minutes between 22-27, return 5. If minutes are above 27 minutes, I need to return 6.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Machine 3 -&amp;nbsp;If minutes between 0-3, return 0.&amp;nbsp;If minutes between 3-8, return 1.&amp;nbsp;If minutes between 8-13, return 2.&amp;nbsp;If minutes between 13-18, return 3.&amp;nbsp;If minutes between 18-23, return 4.&amp;nbsp;If minutes between 23-28. return 5.&amp;nbsp;If minutes above 28 minues, rturn 6.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Machine 4 -&amp;nbsp;If minutes between 0-2, return 0.&amp;nbsp;If minutes between 2-7, return 1.&amp;nbsp;If minutes between 7-12, return 2.&amp;nbsp;If minutes between 12-17, return 3.&amp;nbsp;If minutes between 17-22, return 4,&amp;nbsp;If minutes between 22-27 return 5.&amp;nbsp;If minutes above 27 minutes retun 6.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are 9 machines, so the additonal 5 machines I just want all the display 0.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how I write this?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jul 2021 11:50:09 GMT</pubDate>
    <dc:creator>rebrow31</dc:creator>
    <dc:date>2021-07-21T11:50:09Z</dc:date>
    <item>
      <title>Complex IF Statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1970393#M43260</link>
      <description>&lt;P&gt;I have a table with a machine column and a minutes column. There are 9 different machines and the table is recording the events in which a machine was stopped and how long it was stopped for (the minutes column).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, for just 4 different machines I need to return a value base on the minutes column. But the values returned depend on both the machine and the minutes. For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Machine 1 - If minutes between 0-3, I need to return 0. If minutes between 3-8, I need to return 1. If minutes between 8-13, I need to return 2. If minutes in between 13-18, I need to return 3. If minutes between 18-23, I need to return 4. If minutes between 23-28, I need to return 5. If minutes are above 28, I need to return 6.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Machine 2 - If minutes between 0-2, return 0.&amp;nbsp;If minutes between 2-7, return 1.&amp;nbsp;If minutes between 7-12, return 2.&amp;nbsp;If minutes between 12-17, return 3.&amp;nbsp;If minutes between 17-22, return 4.&amp;nbsp;If minutes between 22-27, return 5. If minutes are above 27 minutes, I need to return 6.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Machine 3 -&amp;nbsp;If minutes between 0-3, return 0.&amp;nbsp;If minutes between 3-8, return 1.&amp;nbsp;If minutes between 8-13, return 2.&amp;nbsp;If minutes between 13-18, return 3.&amp;nbsp;If minutes between 18-23, return 4.&amp;nbsp;If minutes between 23-28. return 5.&amp;nbsp;If minutes above 28 minues, rturn 6.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Machine 4 -&amp;nbsp;If minutes between 0-2, return 0.&amp;nbsp;If minutes between 2-7, return 1.&amp;nbsp;If minutes between 7-12, return 2.&amp;nbsp;If minutes between 12-17, return 3.&amp;nbsp;If minutes between 17-22, return 4,&amp;nbsp;If minutes between 22-27 return 5.&amp;nbsp;If minutes above 27 minutes retun 6.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are 9 machines, so the additonal 5 machines I just want all the display 0.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how I write this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 11:50:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1970393#M43260</guid>
      <dc:creator>rebrow31</dc:creator>
      <dc:date>2021-07-21T11:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Complex IF Statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1971071#M43311</link>
      <description>&lt;P&gt;We still don't know if you need a measure or a calculated column...&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 17:42:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1971071#M43311</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-21T17:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: Complex IF Statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1971920#M43335</link>
      <description>&lt;P&gt;Well that is because I do not know. I am not good on Power BI with this type of thing, which is why I am asking for some help. Maybe you could suggest which should be better?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 05:32:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1971920#M43335</guid>
      <dc:creator>rebrow31</dc:creator>
      <dc:date>2021-07-22T05:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Complex IF Statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1972588#M43353</link>
      <description>&lt;P&gt;I've managed to come up with this which works fine:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Shots = IF (Downtime[Machine] = "DCM01", IF(Downtime[Downtime] &amp;lt; 120, "0", IF(Downtime[Downtime] &amp;lt; 240, "1", IF(Downtime[Downtime] &amp;lt; 360, "2", IF(Downtime[Downtime] &amp;lt; 480, "3", IF(Downtime[Downtime] &amp;lt; 600, "4", IF(Downtime[Downtime] &amp;lt; 720, "5", IF(Downtime[Downtime] &amp;lt; 840, "6", IF(Downtime[Downtime] &amp;lt; 960, "7", IF(Downtime[Downtime] &amp;lt; 27000, "8"))))))))), IF(Downtime[Machine] = "DCM02", IF(Downtime[Downtime] &amp;lt; 300, "0", IF(Downtime[Downtime] &amp;lt; 600, "1", IF(Downtime[Downtime] &amp;lt; 900, "2", IF (Downtime[Downtime] &amp;lt; 1200, "3", IF (Downtime[Downtime] &amp;lt; 1500, "4", IF (Downtime[Downtime] &amp;lt; 1800, "5", IF (Downtime[Downtime] &amp;lt; 27000, "6")))))))))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;However I need to insert 2 more machines in there and it isn't letting me do this because IF function can only have 3 arguments. Which I get but how do I go round being able to put additional rules in for 2 more machines?&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 22 Jul 2021 09:16:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1972588#M43353</guid>
      <dc:creator>rebrow31</dc:creator>
      <dc:date>2021-07-22T09:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: Complex IF Statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1972732#M43357</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="309166" data-lia-user-login="rebrow31" class="lia-mention lia-mention-user"&gt;rebrow31&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&amp;nbsp;Make use of variables to do that:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Shots =&amp;nbsp;&lt;BR /&gt;Var Machine 1= IF(Downtime[Downtime] &amp;lt; 120, "0", IF(Downtime[Downtime] &amp;lt; 240, "1", IF(Downtime[Downtime] &amp;lt; 360, "2", IF(Downtime[Downtime] &amp;lt; 480, "3", IF(Downtime[Downtime] &amp;lt; 600, "4", IF(Downtime[Downtime] &amp;lt; 720, "5", IF(Downtime[Downtime] &amp;lt; 840, "6", IF(Downtime[Downtime] &amp;lt; 960, "7", IF(Downtime[Downtime] &amp;lt; 27000, "8"))))))))), IF(Downtime[Machine] = "DCM02", IF(Downtime[Downtime] &amp;lt; 300, "0", IF(Downtime[Downtime] &amp;lt; 600, "1", IF(Downtime[Downtime] &amp;lt; 900, "2", IF (Downtime[Downtime] &amp;lt; 1200, "3", IF (Downtime[Downtime] &amp;lt; 1500, "4", IF (Downtime[Downtime] &amp;lt; 1800, "5", IF (Downtime[Downtime] &amp;lt; 27000, "6"))))))))&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Var Machine 2= conditions for machine 2&lt;BR /&gt;Var Machine 3=&amp;nbsp;conditions for machine 2&lt;BR /&gt;&lt;BR /&gt;Return&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;IF (Downtime[Machine] = "DCM01",&amp;nbsp;Var Machine 1,&amp;nbsp;IF (Downtime[Machine] = "DCM02",Var Machine 1,&lt;BR /&gt;&amp;nbsp;IF (Downtime[Machine] = "DCM03",&amp;nbsp;Var Machine 3)))&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope this helps!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 09:36:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1972732#M43357</guid>
      <dc:creator>Tanushree_Kapse</dc:creator>
      <dc:date>2021-07-22T09:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Complex IF Statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1972739#M43358</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="309166" data-lia-user-login="rebrow31" class="lia-mention lia-mention-user"&gt;rebrow31&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code is totally unmaintainable. By writing it like this you're shooting yourself in the foot. There is a much better way to write it.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 09:40:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1972739#M43358</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-22T09:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Complex IF Statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1972794#M43359</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="309166" data-lia-user-login="rebrow31" class="lia-mention lia-mention-user"&gt;rebrow31&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If all you want is a calculated column, then you should do it the way I'm going to describe. You should create a&amp;nbsp; MachineConfig table with the following columns:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Machine|LowerBound|UpperBound|Value&lt;BR /&gt;------------------------------------&lt;BR /&gt;Machine1|0|3|0&lt;BR /&gt;Machine1|3|8|1&lt;BR /&gt;...&lt;BR /&gt;Machine2|0|2|0&lt;BR /&gt;Machine2|2|7|1&lt;BR /&gt;...&lt;BR /&gt;This is what it should look like in a good professional model.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Once you've got this table, it's dead easy to add a column with the right Value's to your table T.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;[Value] = /// calculated column in T
var TheMachine = T[Machine]
var TheMinutes = T[Minutes]
var TheValue =
	MAXX(
		FILTER(
			// This filter should return just
			// one row if everything is correctly
			// coded.
			MachineConfig,
			MachineConfig[Machine] = TheMachine
			&amp;amp;&amp;amp;
			// You should decide which bound
			// is inclusive and which is exclusive.
			Machine[LowerBound] &amp;lt;= TheMinutes
			&amp;amp;&amp;amp;
			TheMinutes &amp;lt; Machine[UpperBound]
		),
		MachineConfig[Value]
	)
return
	TheValue&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code will, of course, adjust itself automatically to the entries in the MachineConfig table.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 10:43:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1972794#M43359</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-22T10:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Complex IF Statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1972810#M43360</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="281080" data-lia-user-login="Tanushree_Kapse" class="lia-mention lia-mention-user"&gt;Tanushree_Kapse&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, please do not write code like this as it's completely unmaintainable and plain ugly.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 09:54:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1972810#M43360</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-22T09:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Complex IF Statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1972980#M43364</link>
      <description>&lt;P&gt;Thank you so much for your help. It makes sense, I had no idea about variables. I am still getting an error messgae though, could you shed any light on what might be wrong?:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Shots = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Var Machine 1= IF(Downtime[Downtime] &amp;lt; 2, "0", IF(Downtime[Downtime] &amp;lt; 4, "1", IF(Downtime[Downtime] &amp;lt; 6, "2", IF(Downtime[Downtime] &amp;lt; 8, "3", IF(Downtime[Downtime] &amp;lt; 10, "4", IF(Downtime[Downtime] &amp;lt; 12, "5", IF(Downtime[Downtime] &amp;lt; 14, "6", IF(Downtime[Downtime] &amp;lt; 16, "7", IF(Downtime[Downtime] &amp;lt; 450, "8")))))))))&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Var Machine 2= IF(Downtime[Downtime] &amp;lt; 5, "0", IF(Downtime[Downtime] &amp;lt; 10, "1", IF(Downtime[Downtime] &amp;lt; 15, "2", IF (Downtime[Downtime] &amp;lt; 20, "3", IF (Downtime[Downtime] &amp;lt; 25, "4", IF (Downtime[Downtime] &amp;lt; 30, "5", IF (Downtime[Downtime] &amp;lt; 450, "6")))))))&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Var Machine 3= IF(Downtime[Downtime] &amp;lt; 3, "0", IF(Downtime[Downtime] &amp;lt; 8, "1", IF(Downtime[Downtime] &amp;lt; 13, "2", IF (Downtime[Downtime] &amp;lt; 18, "3", IF(Downtime[Downtime] &amp;lt; 23, "4", IF(Downtime[Downtime] &amp;lt; 28, "5", IF(Downtime[Downtime] &amp;lt; 450, "6")))))))&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Var Machine 9= IF(Downtime[Downtime] &amp;lt; 2, "0", IF(Downtime[Downtime] &amp;lt; 7, "1", IF(Downtime[Downtime] &amp;lt; 12, "2", IF(Downtime[Downtime] &amp;lt; 17, "3", IF(Downtime[Downtime] &amp;lt; 22, "4", IF(Downtime[Downtime] &amp;lt; 27, "5", IF(Downtime[Downtime] &amp;lt; 450, "6")))))))&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Return IF (Downtime[Machine] = "DCM01", Var Machine 1, IF (Downtime[Machine] = "DCM02", Var Machine 2, IF (Downtime[Machine] = "DCM03", Var Machine 3, IF (Downtime[Machine] = "DCM09", Var Machine 9))))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 22 Jul 2021 10:33:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1972980#M43364</guid>
      <dc:creator>rebrow31</dc:creator>
      <dc:date>2021-07-22T10:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: Complex IF Statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1973110#M43368</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="309166" data-lia-user-login="rebrow31" class="lia-mention lia-mention-user"&gt;rebrow31&lt;/a&gt;&amp;nbsp;, The variable names could be a problem...should be a single string. My bad.&lt;BR /&gt;Machine_1, Machine_2.&lt;BR /&gt;&lt;BR /&gt;Also, give a try for&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;'s solution.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 11:02:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-IF-Statement/m-p/1973110#M43368</guid>
      <dc:creator>Tanushree_Kapse</dc:creator>
      <dc:date>2021-07-22T11:02:27Z</dc:date>
    </item>
  </channel>
</rss>

