<?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: Calculate a value depending on which column is applied to the visual in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-value-depending-on-which-column-is-applied-to-the/m-p/3708108#M144251</link>
    <description>&lt;P&gt;To ensure that the grand total returns the sum of one of the three conditions, you can modify your DAX measure. The issue you're facing stems from the fact that when you apply both columns ("Name Seller 1" and "Name Seller 2") to the visual, the HASONEFILTER function does not return true for either of them, causing the grand total to be empty. To address this, you can introduce additional logic to handle the grand total calculation.&lt;/P&gt;&lt;P&gt;Here's the modified DAX measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Single Measure =&lt;BR /&gt;VAR Seller_1_in_Scope = HASONEFILTER('customer table'[Name Seller 1])&lt;BR /&gt;VAR Seller_2_in_Scope = HASONEFILTER('customer table'[Name Seller 2])&lt;/P&gt;&lt;P&gt;RETURN&lt;BR /&gt;SWITCH(&lt;BR /&gt;TRUE(),&lt;BR /&gt;Seller_1_in_Scope &amp;amp;&amp;amp; NOT Seller_2_in_Scope,&lt;BR /&gt;SUMX(VALUES('customer table'[Name Seller 1]), [Goal Seller 1]),&lt;/P&gt;&lt;P&gt;Seller_2_in_Scope &amp;amp;&amp;amp; NOT Seller_1_in_Scope,&lt;BR /&gt;SUMX(VALUES('customer table'[Name Seller 2]), [Goal Seller 2]),&lt;/P&gt;&lt;P&gt;Seller_1_in_Scope &amp;amp;&amp;amp; Seller_2_in_Scope,&lt;BR /&gt;SUMX('customer table', [Goal Seller 1] + [Goal Seller 2]),&lt;/P&gt;&lt;P&gt;// Handle the case when neither Seller 1 nor Seller 2 is in scope&lt;BR /&gt;SUMX(&lt;BR /&gt;'customer table',&lt;BR /&gt;IF(&lt;BR /&gt;Seller_1_in_Scope || Seller_2_in_Scope,&lt;BR /&gt;0, // Return 0 if any one of the columns is in scope&lt;BR /&gt;[Goal Seller 1] + [Goal Seller 2] // Return the sum otherwise&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In this modified measure, we added an additional condition in the &lt;/SPAN&gt;SWITCH&lt;SPAN&gt; statement to handle the scenario when neither Seller 1 nor Seller 2 is in scope. This is achieved by checking if either &lt;/SPAN&gt;Seller_1_in_Scope&lt;SPAN&gt; or &lt;/SPAN&gt;Seller_2_in_Scope&lt;SPAN&gt; is true. If either of them is true, it means that one of the columns is in scope, and in such cases, the measure returns 0 for the grand total. Otherwise, it returns the sum of "Goal Seller 1" and "Goal Seller 2".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Feb 2024 13:23:49 GMT</pubDate>
    <dc:creator>123abc</dc:creator>
    <dc:date>2024-02-19T13:23:49Z</dc:date>
    <item>
      <title>Calculate a value depending on which column is applied to the visual</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-value-depending-on-which-column-is-applied-to-the/m-p/3708019#M144245</link>
      <description>&lt;P&gt;I need to create a DAX measure that calculates the sales value depending on which table column is applied to the table visual. In other words, i need to check whether a specified column is applied to the visual and then calculate the corresponding values.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have a table that is basically a customer portfolio and this table contains the fields "Customer Name", "Seller Name 1" and "Seller Name 2". Each customer is served by two types of salespeople, salesperson 1 and salesperson 2.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;If the "Name Seller 1" column is applied to the visual then calculate the "Goal Seller 1" measure for each row of the visual and also for the grand total.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If the "Name Seller 2" column is applied to the visual then calculate the "Goal Seller 2" measurement for each row of the visual and also for the grand total.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If both columns "Name Seller 1" and "Name Seller 2" are applied to the visual, then calculate the sum of the two measures "Name Seller 1" and "Name Seller 2" for each row and also for the grand total.&lt;/P&gt;&lt;P&gt;See the measurement I took below using the SWITCH function, it checks the three conditionals and correctly calculates the values for each line, but the grand total value is returning empty instead of the total of the condition that is being satisfied&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;LI-CODE lang="css"&gt;Single Measure = 

VAR Seller_1_in_Scope = HASONEFILTER('customer table'[Name Seller1])
VAR Seller_2_in_Scope = HASONEFILTER('customer table'[Name Seller2])

RETURN
SWITCH(
    TRUE(),
    Seller_1_in_Scope &amp;amp;&amp;amp; NOT Seller_2_in_Scope, 
    SUMX(
        VALUES('customer table'[Name Seller1]),[Goal Seller 1]),

    Seller_2_in_Scope &amp;amp;&amp;amp; NOT Seller_1_in_Scope, 
    SUMX(
        VALUES('customer table'[Name Seller2]),[Goal Seller 2]),

    Seller_1_in_Scope &amp;amp;&amp;amp; Seller_2_in_Scope, 
    SUMX(
        'customer table',
        CALCULATE([Goal Seller 1] + [Goal Seller 2])
)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I need to ensure that the grand total returns the sum of one of the three conditions.&lt;BR /&gt;If you know of another way to achieve this goal please let me know.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://lasdobrasilcombr-my.sharepoint.com/:u:/g/personal/rai_santos_las_app_br/Eax8ktdXV4VOt8gqU3ENYPABTf_V4vBpQrUfYPSOCxncsw?e=4OlKOo" target="_self"&gt;DOWNLOAD PBIX HERE&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 14:14:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-value-depending-on-which-column-is-applied-to-the/m-p/3708019#M144245</guid>
      <dc:creator>Rai_BI</dc:creator>
      <dc:date>2024-02-19T14:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a value depending on which column is applied to the visual</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-value-depending-on-which-column-is-applied-to-the/m-p/3708108#M144251</link>
      <description>&lt;P&gt;To ensure that the grand total returns the sum of one of the three conditions, you can modify your DAX measure. The issue you're facing stems from the fact that when you apply both columns ("Name Seller 1" and "Name Seller 2") to the visual, the HASONEFILTER function does not return true for either of them, causing the grand total to be empty. To address this, you can introduce additional logic to handle the grand total calculation.&lt;/P&gt;&lt;P&gt;Here's the modified DAX measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Single Measure =&lt;BR /&gt;VAR Seller_1_in_Scope = HASONEFILTER('customer table'[Name Seller 1])&lt;BR /&gt;VAR Seller_2_in_Scope = HASONEFILTER('customer table'[Name Seller 2])&lt;/P&gt;&lt;P&gt;RETURN&lt;BR /&gt;SWITCH(&lt;BR /&gt;TRUE(),&lt;BR /&gt;Seller_1_in_Scope &amp;amp;&amp;amp; NOT Seller_2_in_Scope,&lt;BR /&gt;SUMX(VALUES('customer table'[Name Seller 1]), [Goal Seller 1]),&lt;/P&gt;&lt;P&gt;Seller_2_in_Scope &amp;amp;&amp;amp; NOT Seller_1_in_Scope,&lt;BR /&gt;SUMX(VALUES('customer table'[Name Seller 2]), [Goal Seller 2]),&lt;/P&gt;&lt;P&gt;Seller_1_in_Scope &amp;amp;&amp;amp; Seller_2_in_Scope,&lt;BR /&gt;SUMX('customer table', [Goal Seller 1] + [Goal Seller 2]),&lt;/P&gt;&lt;P&gt;// Handle the case when neither Seller 1 nor Seller 2 is in scope&lt;BR /&gt;SUMX(&lt;BR /&gt;'customer table',&lt;BR /&gt;IF(&lt;BR /&gt;Seller_1_in_Scope || Seller_2_in_Scope,&lt;BR /&gt;0, // Return 0 if any one of the columns is in scope&lt;BR /&gt;[Goal Seller 1] + [Goal Seller 2] // Return the sum otherwise&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In this modified measure, we added an additional condition in the &lt;/SPAN&gt;SWITCH&lt;SPAN&gt; statement to handle the scenario when neither Seller 1 nor Seller 2 is in scope. This is achieved by checking if either &lt;/SPAN&gt;Seller_1_in_Scope&lt;SPAN&gt; or &lt;/SPAN&gt;Seller_2_in_Scope&lt;SPAN&gt; is true. If either of them is true, it means that one of the columns is in scope, and in such cases, the measure returns 0 for the grand total. Otherwise, it returns the sum of "Goal Seller 1" and "Goal Seller 2".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Feb 2024 13:23:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-value-depending-on-which-column-is-applied-to-the/m-p/3708108#M144251</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2024-02-19T13:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a value depending on which column is applied to the visual</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-value-depending-on-which-column-is-applied-to-the/m-p/3708210#M144263</link>
      <description>&lt;P&gt;Sorry but your measurement doesn't work well. Unlike my measure, your measure is returning a value for the grand total, but it is returning an incorrect single value because it is returning the same value regardless of which column is applied to the visual.&lt;/P&gt;&lt;P&gt;&lt;img /&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;</description>
      <pubDate>Mon, 19 Feb 2024 14:01:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-value-depending-on-which-column-is-applied-to-the/m-p/3708210#M144263</guid>
      <dc:creator>Rai_BI</dc:creator>
      <dc:date>2024-02-19T14:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a value depending on which column is applied to the visual</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-value-depending-on-which-column-is-applied-to-the/m-p/3710148#M144355</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="570958" data-lia-user-login="Rai_BI" class="lia-mention lia-mention-user"&gt;Rai_BI&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In Power BI, if your measure doesn't show totals, it might be because your measure calculation logic doesn't allow it to add up on all rows.&lt;/P&gt;
&lt;P&gt;Perhaps you can use the following DAX expression:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Single Measure test =

// When the both columns are in scope i need to display the sum of the two measures for each line and at grid total.

VAR Seller_1_in_Scope = HASONEFILTER('customer table'[Name Seller1])

VAR Seller_2_in_Scope = HASONEFILTER('customer table'[Name Seller2])



RETURN

IF(Seller_1_in_Scope||Seller_2_in_Scope,

SWITCH(

    TRUE(),

    Seller_1_in_Scope &amp;amp;&amp;amp; NOT Seller_2_in_Scope,

    SUMX(

        VALUES('customer table'[Name Seller1]),[Goal Seller 1]),



    Seller_2_in_Scope &amp;amp;&amp;amp; NOT Seller_1_in_Scope,

    SUMX(

        VALUES('customer table'[Name Seller2]),[Goal Seller 2]),



    Seller_1_in_Scope &amp;amp;&amp;amp; Seller_2_in_Scope,

    SUMX(

        SUMMARIZE(

            'customer table',

            'customer table'[Name Seller1],'customer table'[Name Seller2]),

            CALCULATE([Goal Seller 1] + [Goal Seller 2])

)),

CALCULATE([Goal Seller 1]+[Goal Seller 2]))

&lt;/LI-CODE&gt;
&lt;P&gt;Here is my preview:&lt;/P&gt;
&lt;P&gt;&lt;img /&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;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-Get-Your-Question-Answered-Quickly%2Fba-p%2F38490&amp;amp;data=05%7C02%7Cv-yohua%40microsoft.com%7C3482f2d30a1848dc1c7608dc31e69c10%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638440113742798350%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&amp;amp;sdata=rYbSVsMd9uYbdVhQTrdv4S7mCMzMmqyp5kas0Zkz0YI%3D&amp;amp;reserved=0" target="_blank"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Yongkang Hua&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 07:40:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-a-value-depending-on-which-column-is-applied-to-the/m-p/3710148#M144355</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-20T07:40:04Z</dc:date>
    </item>
  </channel>
</rss>

