<?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: Measure with different outputs based on condition in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-different-outputs-based-on-condition/m-p/2087221#M47477</link>
    <description>&lt;P&gt;Works very well!!&lt;/P&gt;&lt;P&gt;Still intrigued why we need to work around it like that, doesn't seem like a efficient solution... PowerBI has it's problems, it shouldn't require a scalar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, thanks so much!&lt;/P&gt;</description>
    <pubDate>Mon, 20 Sep 2021 23:56:51 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-09-20T23:56:51Z</dc:date>
    <item>
      <title>Measure with different outputs based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-different-outputs-based-on-condition/m-p/2087203#M47470</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a measure that calculates based on a condition: If Table1[Column1] = "KPI1" then Formula1 else Formula2.&lt;/P&gt;&lt;P&gt;The logic is very simple, but I can't get Power BI to read Table[Column] in my IF statement, it only allows me to use other measures from Table1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Formula1&amp;nbsp;&lt;/EM&gt;= &lt;EM&gt;DIVIDE(Sum(Num), Sum(Den), 0)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Formula2&amp;nbsp;= DIVIDE(Sum(Num), Average(Den), 0)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how to work around that?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 23:41:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-different-outputs-based-on-condition/m-p/2087203#M47470</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-20T23:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: Measure with different outputs based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-different-outputs-based-on-condition/m-p/2087205#M47471</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;Try:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure =
  IF(
    MAX('Table1'[Column]="KPI1",
    DIVIDE(Sum(Num), Sum(Den), 0),
    DIVIDE(Sum(Num), Average(Den), 0)
  )&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 20 Sep 2021 23:43:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-different-outputs-based-on-condition/m-p/2087205#M47471</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-09-20T23:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Measure with different outputs based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-different-outputs-based-on-condition/m-p/2087209#M47472</link>
      <description>&lt;P&gt;Try this&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MeasureName =
VAR varValue =
    MAX( TableName[Field] )
RETURN
    IF(
        varValue = "KPI1",
        DIVIDE(
            SUM( Table[Num] ),
            SUM( Table[Den] ),
            0
        ),
        DIVIDE(
            SUM( Table[Num] ),
            AVERAGE( Table[Den] ),
            0
        )
    )
&lt;/LI-CODE&gt;
&lt;P&gt;You need to convert the field to a scalar value, which MAX does when used like this. MIN will give you the same result.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 23:46:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-different-outputs-based-on-condition/m-p/2087209#M47472</guid>
      <dc:creator>edhans</dc:creator>
      <dc:date>2021-09-20T23:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Measure with different outputs based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-different-outputs-based-on-condition/m-p/2087221#M47477</link>
      <description>&lt;P&gt;Works very well!!&lt;/P&gt;&lt;P&gt;Still intrigued why we need to work around it like that, doesn't seem like a efficient solution... PowerBI has it's problems, it shouldn't require a scalar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, thanks so much!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 23:56:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-different-outputs-based-on-condition/m-p/2087221#M47477</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-20T23:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: Measure with different outputs based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-different-outputs-based-on-condition/m-p/2087224#M47478</link>
      <description>&lt;P&gt;Everything in DAX requires it to either be scalar, column, or table,. and are not interchangable.&lt;BR /&gt;&lt;BR /&gt;You cannot say IF(Table[Column] = "X", 1, 0) because in a&amp;nbsp;&lt;EM&gt;measure&lt;/EM&gt; it doesn't know how to process that column. It needs to be converted into a scalar value. SUM, MAX, AVERAGE, whatever.&lt;BR /&gt;&lt;BR /&gt;In a Calculated Column you&amp;nbsp;&lt;EM&gt;can&lt;/EM&gt; do that because those have Row Context. Measures do not. It is a very hard concept to learn right off the bat, but once you do it becomes clear. Row Context and Filter Context are two completely different animals. Measures understand Filter Context, not Row Context.&lt;BR /&gt;&lt;BR /&gt;There is another concept called Context Transition, and that is for another post.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_tears_of_joy:"&gt;😂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Glad you have a solution!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2021 00:01:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-different-outputs-based-on-condition/m-p/2087224#M47478</guid>
      <dc:creator>edhans</dc:creator>
      <dc:date>2021-09-21T00:01:27Z</dc:date>
    </item>
  </channel>
</rss>

