<?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: Avoid adapting a measure in a table, and IF() returning too many rows in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2370624#M60821</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your answer.&lt;BR /&gt;I wrapped my original formula in a CALCULATE and added the modifiers and it works fine unless I want to select two categories at the same time:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Do you know how we can allow several categories to be selected? The same problem occurs if I filter something else than the categories.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regarding the IF statement, I don't want to return the rows that are not in the selected categories, so I re-wrote your formula to the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Mesure = 
IF ( 
    ISBLANK ( [average_value_weighted_by_sales] ),
    BLANK(),
    IF ( 
        [ContValue] &amp;lt;= [average_value_weighted_by_sales],
        "OK",
        "KO"
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Thank you in advance!&lt;/P&gt;</description>
    <pubDate>Wed, 02 Mar 2022 16:27:23 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-03-02T16:27:23Z</dc:date>
    <item>
      <title>Avoid adapting a measure in a table, and IF() returning too many rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2367817#M60673</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a WeTransfer for the PBI in case you want to help me:&amp;nbsp;&lt;A href="https://we.tl/t-sfdijb0Q4Y" target="_self"&gt;https://we.tl/t-sfdijb0Q4Y&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I have 3 tables, linked together in the follwoing way:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far, for a selected Category (selected with a slicer on the category's name), I display all the information that I have in the Table &lt;EM&gt;Feuil2&lt;/EM&gt; and the sum of &lt;STRONG&gt;Value&lt;/STRONG&gt; from &lt;EM&gt;Feuil3&lt;/EM&gt;. In addition, I computed a weighted average of the &lt;STRONG&gt;Value&lt;/STRONG&gt; for each attribute in the selected category, weighted by their sales. For this, I used the following DAX formula:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;average_value_weighted_by_sales =
DIVIDE( 
    SUMX(Feuil3,
         Feuil3[Value] * CALCULATE(SUM(Feuil2[AttributeSales]))
    ),
    CALCULATE(SUM(Feuil2[AttributeSales]))
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Power BI looks like that:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to do it add a column to the Table visual that would take the value "OK" if the sum of an attribute's &lt;STRONG&gt;value&lt;/STRONG&gt; is smaller than the displayed &lt;STRONG&gt;average_value_weighted_by_sales&lt;/STRONG&gt;, or "KO" if the sum is greater.&lt;/P&gt;&lt;P&gt;In my example, that'd mean that I'd have "KO" for the first row (since 1.94383 &amp;gt; 1.81081), "OK" for the second row (since 1.51867 &amp;lt;= 1.81081), and "KO" for the last row&amp;nbsp;(since 2.2050 &amp;gt; 1.81081).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course, I would need this to be dynamic when we select a new category.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While doing to do this, I have faced two problems:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The measure that I created adapts to the context (I guess that's the name?), meaning that if for an attribute I ask how its value compares to the measure, it's always equal since the measure wil be computed based on the attribute only. We can see that by placing the measure in the visual and we will see that the columns &lt;STRONG&gt;Value&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;average_value_weighted_by_sales&lt;/STRONG&gt; will be equal.&lt;/LI&gt;&lt;LI&gt;Th function IF (which I think is the next step) returns all the rows and not only the ones I filtered with the slicer.&lt;BR /&gt;&lt;img /&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for you help!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 17:04:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2367817#M60673</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-01T17:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid adapting a measure in a table, and IF() returning too many rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2369122#M60732</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt; &lt;BR /&gt;Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 06:00:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2369122#M60732</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-03-02T06:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid adapting a measure in a table, and IF() returning too many rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2369436#M60745</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;There was a a link to a WeTransfer in my post. Here it is again, let me know if it doesn't work: &lt;A href="https://wetransfer.com/downloads/53f3905055ea95bfad84e220a629287620220301153420/91c4df" target="_blank" rel="noopener"&gt;link tp sample pbix&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 08:15:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2369436#M60745</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-02T08:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid adapting a measure in a table, and IF() returning too many rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2369901#M60771</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Here is the sample file with the solution&amp;nbsp;&lt;A href="https://www.dropbox.com/t/6EOcCJOeKP6UIZOu" target="_blank" rel="noopener"&gt;https://www.dropbox.com/t/6EOcCJOeKP6UIZOu&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Just adjust the formula of [&lt;SPAN&gt;average_value_weighted_by_sales] by wrapping&amp;nbsp;it with CALCULATE to apply the required modifiers as follows:&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;LI-CODE lang="markup"&gt;average_value_weighted_by_sales = 
CALCULATE (
    DIVIDE ( 
        SUMX ( Feuil3,
            Feuil3[Value] * CALCULATE ( SUM ( Feuil2[AttributeSales] ) )
        ),
        CALCULATE ( SUM( Feuil2[AttributeSales] ) )
    ),
    REMOVEFILTERS (),
    VALUES ( Feuil1[CategoryName] )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then you can use it in your IF statement.&amp;nbsp;&lt;BR /&gt;&lt;img /&gt;&lt;img /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Please note that you need to use the matrix visual as the filter context in the table visual would be too complicated to handle. Further I had to create a filter measure which is hidden inside the matrix just to force it not to hide blanks. I guess you can do that throughout&amp;nbsp;some settings as well but I personally prefer&amp;nbsp;playing with DAX.&lt;BR /&gt;Please let me know if you have any question.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;U&gt;Note:&lt;/U&gt;&lt;/STRONG&gt; &lt;EM&gt;the table names you've been using in the file were confusing to me therefore, I used different names inside the file. Let me know if you need the same with the old names&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 11:46:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2369901#M60771</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-02T11:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid adapting a measure in a table, and IF() returning too many rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2369958#M60778</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Just noticed that you need to disply all "Names". Please redownload the file&amp;nbsp;&lt;A href="https://www.dropbox.com/t/VmDYVcL9fFwhdV57" target="_blank"&gt;https://www.dropbox.com/t/VmDYVcL9fFwhdV57&lt;/A&gt;&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 12:11:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2369958#M60778</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-02T12:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid adapting a measure in a table, and IF() returning too many rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2370624#M60821</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your answer.&lt;BR /&gt;I wrapped my original formula in a CALCULATE and added the modifiers and it works fine unless I want to select two categories at the same time:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Do you know how we can allow several categories to be selected? The same problem occurs if I filter something else than the categories.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regarding the IF statement, I don't want to return the rows that are not in the selected categories, so I re-wrote your formula to the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Mesure = 
IF ( 
    ISBLANK ( [average_value_weighted_by_sales] ),
    BLANK(),
    IF ( 
        [ContValue] &amp;lt;= [average_value_weighted_by_sales],
        "OK",
        "KO"
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 16:27:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2370624#M60821</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-02T16:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid adapting a measure in a table, and IF() returning too many rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2370791#M60831</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;This one works for any selection&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;average_value_weighted_by_sales = 
DIVIDE (
    SUMX ( 
        ALL ( Sales[ID], Sales[Name] ),
        CALCULATE ( 
            SUMX (
                Context,
                Context[Value] * CALCULATE ( SUM ( Sales[Sales] ) )
            )
        )
    ),
    SUMX (
        ALL ( Sales[ID], Sales[Name] ),
        CALCULATE ( 
            SUM ( Sales[Sales] )
        )
    )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 02 Mar 2022 17:54:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avoid-adapting-a-measure-in-a-table-and-IF-returning-too-many/m-p/2370791#M60831</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-02T17:54:10Z</dc:date>
    </item>
  </channel>
</rss>

