<?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 How to calculate a value depending on the column in the visual in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-a-value-depending-on-the-column-in-the-visual/m-p/3714382#M144554</link>
    <description>&lt;P&gt;Hi! Please, some one help me to solve this issue.&amp;nbsp;I've been trying for a long time and I'm failing&lt;/P&gt;&lt;P&gt;&lt;A href="https://lasdobrasilcombr-my.sharepoint.com/:u:/g/personal/rai_santos_las_app_br/EfR46QOOFgZGg6dulzsFboABpMOZjkw4p1c2OhJt6TQ1SA?e=vM5PGp" target="_self"&gt;Download PBIX here&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the fields parameter which allows me to add multiple columns from different dimension tables to the visual.&lt;/P&gt;&lt;P&gt;I need to create a DAX measure that calculates the salesperson's target value depending on which 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.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Take a look&lt;/P&gt;&lt;P&gt;I'm just adding the "Year/"Month" column to the visual. The sum is ok.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I'm adding the "Year/"Month" and &lt;STRONG&gt;"Name Seller1"&lt;/STRONG&gt; column to the visual. The sum is not correct, because I only need to see the seller1's goal&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I'm adding the "Year/"Month" and &lt;STRONG&gt;"Name Seller2"&lt;/STRONG&gt; column to the visual. The sum is not correct, because I only need to see the seller2's goal&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I'm adding the "Year/"Month" and &lt;STRONG&gt;"Name Seller 1"&lt;/STRONG&gt; and &lt;STRONG&gt;"Name Seller2"&lt;/STRONG&gt; column to the visual. The sum is correct but it's because the grand total always returns the sum of the two goals. It doesn't check if it's one of the conditionals of the SWITCH that is active.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In other words, the DAX measure must check whether only one column or both "Seller Name1" and "Seller Name2" columns are in the visual to calculate the correct value according to the presence of the columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If only the "Name Seller 1" column is applied to the visual, calculate the "Goal Seller 1" measure for each row in the visual and also for the grand total.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If only the "Name Seller 2" column is applied to the visual, calculate the "Goal Seller 2" measure for each row in the visual and also for the grand total.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If both the "Name Seller 1" and "Name Seller 2" columns are applied to the visual, calculate the sum of the two measures "Goal Seller 1" and "Goal Seller 2" for each row and also for the grand total.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See below the measure I took using the SWITCH function, it checks the three conditionals and correctly calculates the values of each line, but the overall total value is returning an incorrect sum, as it is always returning the sum of the two measurements "Goal Seller 1" and "Goal Seller 2" are independent of which conditional is being satisfied in the SWITCH function.&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(
        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;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Feb 2024 13:41:05 GMT</pubDate>
    <dc:creator>Rai_BI</dc:creator>
    <dc:date>2024-02-21T13:41:05Z</dc:date>
    <item>
      <title>How to calculate a value depending on the column in the visual</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-a-value-depending-on-the-column-in-the-visual/m-p/3714382#M144554</link>
      <description>&lt;P&gt;Hi! Please, some one help me to solve this issue.&amp;nbsp;I've been trying for a long time and I'm failing&lt;/P&gt;&lt;P&gt;&lt;A href="https://lasdobrasilcombr-my.sharepoint.com/:u:/g/personal/rai_santos_las_app_br/EfR46QOOFgZGg6dulzsFboABpMOZjkw4p1c2OhJt6TQ1SA?e=vM5PGp" target="_self"&gt;Download PBIX here&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the fields parameter which allows me to add multiple columns from different dimension tables to the visual.&lt;/P&gt;&lt;P&gt;I need to create a DAX measure that calculates the salesperson's target value depending on which 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.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Take a look&lt;/P&gt;&lt;P&gt;I'm just adding the "Year/"Month" column to the visual. The sum is ok.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I'm adding the "Year/"Month" and &lt;STRONG&gt;"Name Seller1"&lt;/STRONG&gt; column to the visual. The sum is not correct, because I only need to see the seller1's goal&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I'm adding the "Year/"Month" and &lt;STRONG&gt;"Name Seller2"&lt;/STRONG&gt; column to the visual. The sum is not correct, because I only need to see the seller2's goal&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I'm adding the "Year/"Month" and &lt;STRONG&gt;"Name Seller 1"&lt;/STRONG&gt; and &lt;STRONG&gt;"Name Seller2"&lt;/STRONG&gt; column to the visual. The sum is correct but it's because the grand total always returns the sum of the two goals. It doesn't check if it's one of the conditionals of the SWITCH that is active.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In other words, the DAX measure must check whether only one column or both "Seller Name1" and "Seller Name2" columns are in the visual to calculate the correct value according to the presence of the columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If only the "Name Seller 1" column is applied to the visual, calculate the "Goal Seller 1" measure for each row in the visual and also for the grand total.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If only the "Name Seller 2" column is applied to the visual, calculate the "Goal Seller 2" measure for each row in the visual and also for the grand total.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If both the "Name Seller 1" and "Name Seller 2" columns are applied to the visual, calculate the sum of the two measures "Goal Seller 1" and "Goal Seller 2" for each row and also for the grand total.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See below the measure I took using the SWITCH function, it checks the three conditionals and correctly calculates the values of each line, but the overall total value is returning an incorrect sum, as it is always returning the sum of the two measurements "Goal Seller 1" and "Goal Seller 2" are independent of which conditional is being satisfied in the SWITCH function.&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(
        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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 13:41:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-a-value-depending-on-the-column-in-the-visual/m-p/3714382#M144554</guid>
      <dc:creator>Rai_BI</dc:creator>
      <dc:date>2024-02-21T13:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate a value depending on the column in the visual</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-a-value-depending-on-the-column-in-the-visual/m-p/3715170#M144594</link>
      <description>&lt;P&gt;The 'Total' row does not have a Name Seller1 or NameSeller2 context.&lt;BR /&gt;You can try the following measure which should give the correct result.&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;Single Measure v2 = 
var _s1Selected =
CONTAINS(SUMMARIZE(Parameter, Parameter[Parâmetro], Parameter[Parâmetro Campos]), Parameter[Parâmetro], "Name Seller1")
var _s2Selected =
CONTAINS(SUMMARIZE(Parameter, Parameter[Parâmetro], Parameter[Parâmetro Campos]), Parameter[Parâmetro], "Name Seller2")
var _countRows =
ISFILTERED(Parameter)
var _result =
SWITCH(
    TRUE(),
    _s1Selected &amp;amp;&amp;amp; NOT(_s2Selected) &amp;amp;&amp;amp; _countRows, [Goal Seller 1],
    _s2Selected &amp;amp;&amp;amp; NOT(_s1Selected) &amp;amp;&amp;amp; _countRows, [Goal Seller 2],
    [Goal Seller 1] + [Goal Seller 2]
)
Return
_result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 19:31:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-a-value-depending-on-the-column-in-the-visual/m-p/3715170#M144594</guid>
      <dc:creator>jgeddes</dc:creator>
      <dc:date>2024-02-21T19:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate a value depending on the column in the visual</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-a-value-depending-on-the-column-in-the-visual/m-p/3721950#M144947</link>
      <description>&lt;P&gt;Thank you very much&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2024 14:28:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-calculate-a-value-depending-on-the-column-in-the-visual/m-p/3721950#M144947</guid>
      <dc:creator>Rai_BI</dc:creator>
      <dc:date>2024-02-25T14:28:53Z</dc:date>
    </item>
  </channel>
</rss>

