<?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: DAX: Calculate Total Sales based on product type in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Calculate-Total-Sales-based-on-product-type/m-p/3495994#M133932</link>
    <description>&lt;P&gt;It seems like you want to create a DAX measure in Power BI to calculate the total sales by product type, where for Product Type 2, you want to use 'Net Sales', and for other product types (1, 3, 4, 5), you want to use 'Gross Sales'. However, your current DAX measure is returning individual values, and you want it to calculate the total sales as well.&lt;/P&gt;&lt;P&gt;You can achieve this by modifying your DAX measure slightly. You can use the SUMX function to iterate through the table and calculate the sum of sales for each product type. Here's how you can modify your measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Total Sales by Product Type =&lt;BR /&gt;SUMX(&lt;BR /&gt;VALUES(Product[ProductTypeId]), -- Iterate through unique Product Types&lt;BR /&gt;VAR NETSALES = CALCULATE([NetSales])&lt;BR /&gt;RETURN&lt;BR /&gt;SWITCH(&lt;BR /&gt;Product[ProductTypeId],&lt;BR /&gt;2, NETSALES,&lt;BR /&gt;1, [GrossSales],&lt;BR /&gt;3, [GrossSales],&lt;BR /&gt;4, [GrossSales],&lt;BR /&gt;5, [GrossSales]&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This measure will iterate through unique Product Types and calculate the sales for each type using your specified logic (Net Sales for Product Type 2, Gross Sales for others), and then sum these values to give you the total sales by product type.&lt;/P&gt;&lt;P&gt;Now, when you use this measure in your Power BI visuals or tables, it should correctly display the total sales by product type, considering the individual sales values for each product type and summing them up as well.&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>Wed, 25 Oct 2023 09:43:39 GMT</pubDate>
    <dc:creator>123abc</dc:creator>
    <dc:date>2023-10-25T09:43:39Z</dc:date>
    <item>
      <title>DAX: Calculate Total Sales based on product type</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Calculate-Total-Sales-based-on-product-type/m-p/3495956#M133927</link>
      <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently creating a power BI report and using DAX to find total sales by product type. Confusingly 1 product has be calculated using 'Net Sales' and not 'Gross Sales'. Please see the formula I have created below:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Measure =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;NETSALES&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[NetSales]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&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;SPAN&gt;4&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[GrossSales]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[GrossSales]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;It works for individual sales on the power BI visuals but I need it to simultaneously add up as well. So if you looked at the table all the individual values are correct but the whole column is not summing up if that makes sense.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Any help would be greatly appreciated!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Luke&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 25 Oct 2023 09:30:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Calculate-Total-Sales-based-on-product-type/m-p/3495956#M133927</guid>
      <dc:creator>LABrowne</dc:creator>
      <dc:date>2023-10-25T09:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Calculate Total Sales based on product type</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Calculate-Total-Sales-based-on-product-type/m-p/3495994#M133932</link>
      <description>&lt;P&gt;It seems like you want to create a DAX measure in Power BI to calculate the total sales by product type, where for Product Type 2, you want to use 'Net Sales', and for other product types (1, 3, 4, 5), you want to use 'Gross Sales'. However, your current DAX measure is returning individual values, and you want it to calculate the total sales as well.&lt;/P&gt;&lt;P&gt;You can achieve this by modifying your DAX measure slightly. You can use the SUMX function to iterate through the table and calculate the sum of sales for each product type. Here's how you can modify your measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Total Sales by Product Type =&lt;BR /&gt;SUMX(&lt;BR /&gt;VALUES(Product[ProductTypeId]), -- Iterate through unique Product Types&lt;BR /&gt;VAR NETSALES = CALCULATE([NetSales])&lt;BR /&gt;RETURN&lt;BR /&gt;SWITCH(&lt;BR /&gt;Product[ProductTypeId],&lt;BR /&gt;2, NETSALES,&lt;BR /&gt;1, [GrossSales],&lt;BR /&gt;3, [GrossSales],&lt;BR /&gt;4, [GrossSales],&lt;BR /&gt;5, [GrossSales]&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This measure will iterate through unique Product Types and calculate the sales for each type using your specified logic (Net Sales for Product Type 2, Gross Sales for others), and then sum these values to give you the total sales by product type.&lt;/P&gt;&lt;P&gt;Now, when you use this measure in your Power BI visuals or tables, it should correctly display the total sales by product type, considering the individual sales values for each product type and summing them up as well.&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>Wed, 25 Oct 2023 09:43:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Calculate-Total-Sales-based-on-product-type/m-p/3495994#M133932</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-10-25T09:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Calculate Total Sales based on product type</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Calculate-Total-Sales-based-on-product-type/m-p/3496014#M133934</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="636377" data-lia-user-login="LABrowne" class="lia-mention lia-mention-user"&gt;LABrowne&lt;/a&gt;, my suggested solution is to change your measure formula to this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure = 
    SUMX(
        VALUES(Product[ProductTypeId]),
        SWITCH(Product[ProductTypeId],
            1, [NetSales],
            [GrossSales]
        )
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 25 Oct 2023 09:49:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Calculate-Total-Sales-based-on-product-type/m-p/3496014#M133934</guid>
      <dc:creator>EylesIT</dc:creator>
      <dc:date>2023-10-25T09:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Calculate Total Sales based on product type</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Calculate-Total-Sales-based-on-product-type/m-p/3496400#M133949</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 12:45:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Calculate-Total-Sales-based-on-product-type/m-p/3496400#M133949</guid>
      <dc:creator>LABrowne</dc:creator>
      <dc:date>2023-10-25T12:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Calculate Total Sales based on product type</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Calculate-Total-Sales-based-on-product-type/m-p/3496849#M133979</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 15:42:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Calculate-Total-Sales-based-on-product-type/m-p/3496849#M133979</guid>
      <dc:creator>LABrowne</dc:creator>
      <dc:date>2023-10-25T15:42:03Z</dc:date>
    </item>
  </channel>
</rss>

