<?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: Weighted Average Based on Multiple Critera and Filters in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1160585#M17794</link>
    <description>&lt;P&gt;2. I would like the year as an attribute. I would like to display the results for the measure based on the results of year [Reporting Year]. So the % of Year measure is on the Y-axis and Reporting Year is on the X-axis.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jun 2020 16:11:48 GMT</pubDate>
    <dc:creator>JustinShultz</dc:creator>
    <dc:date>2020-06-15T16:11:48Z</dc:date>
    <item>
      <title>Weighted Average Based on Multiple Critera and Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1156248#M17663</link>
      <description>&lt;P&gt;Hello Power Bi Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to Power Bi and trying to understand how to do a fairly complex DAX calculation. I have several weighted averages I would like to calculate but the denomanator is changing based on several criteria. Heres a short snippet of my example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Project Name&lt;/TD&gt;&lt;TD&gt;Sector&lt;/TD&gt;&lt;TD&gt;Reporting Year&lt;/TD&gt;&lt;TD&gt;% Savings&lt;/TD&gt;&lt;TD&gt;Area&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Project 1&lt;/TD&gt;&lt;TD&gt;HE&lt;/TD&gt;&lt;TD&gt;2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gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The numbers I am trying to calucalte include:&lt;/P&gt;&lt;P&gt;Area Weighted % Savings by Reporting Year = % Saving * Area / SUM(Area by Reporting Year)&lt;/P&gt;&lt;P&gt;Area Weighted % Savings by Reporting Year and Sector = % Savings * Area / SUM(Area by Reporting Year and Sector)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My method so far as been to create individual columns for each of these steps.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Area by Year = CALCULATE(SUM('Table'[Area]), ALLEXCEPT('Table','Table'[Reporting Year]))&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;Which creates a column of the summed area for the same year of the Reporting Year&lt;/LI&gt;&lt;LI&gt;I tried using a measure and then having the sum filtered on the Report tab based on removing all other Reporting Years but this did not change the SUM.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then setup Area by Reporting Year and Sector, one per column:&lt;/P&gt;&lt;PRE&gt;HE Area by Year = CALCULATE(&lt;BR /&gt;SUM('Table'[Area]), &lt;BR /&gt;ALLEXCEPT('Table','Table'[Reporting Year]), &lt;BR /&gt;'Table'[Sector]="HE")&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;This step was repeated for each of the different sectors and has become quite tedious and difficult to manage when creating graphics on the Report tab.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then use each of these in the denomenator of the Area Weighted % Savings equation. With the number calculated I'm creating visualizations in the Report tab and trying to filter by Reporting Year and Sector.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe there is some way I can get the SUM Total Area by Report Year, Sector, and other criteria without creating so many columns. Is there an easier way to do this with a DAX equation?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 16:08:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1156248#M17663</guid>
      <dc:creator>JustinShultz</dc:creator>
      <dc:date>2020-06-12T16:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average Based on Multiple Critera and Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1156586#M17673</link>
      <description>&lt;P&gt;You don't really want to use columns for that.&amp;nbsp; Transform them to measures.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you create your DAX formula, use copious amounts of variables to validate that your intermediate steps do what you want.&amp;nbsp; Since in DAX everything is a table (just sometimes a single row/single column table), use CONCATENATEX to visualize your intermediate results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example for the first measure would be&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;% by year = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var y = selectedvalue('Table'[Reporting Year])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var s = SELECTEDVALUE('Table'[% Savings])*SELECTEDVALUE('Table'[Area])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var t = CALCULATE(sum('Table'[Area]),Filter(ALL('Table'),'Table'[Reporting Year]=y))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var r = divide(s,t)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return r&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;This is a bit excessive but it demonstrates the general approach.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 12 Jun 2020 19:57:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1156586#M17673</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2020-06-12T19:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average Based on Multiple Critera and Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1160536#M17788</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;, thank you for your reply. I was not aware that you can use var to hold variable information. I have two follow up questions to expand my understanding for more applications.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;How would I expand the FILTER() or other functions to include additional critera? For example, while keeping the year filter, I can then add a filter for the sector like "HE" or "GO"? I would like to do another weighted average based on each year and each sector.&lt;/LI&gt;&lt;LI&gt;I am having trouble using the measure to visualize values over multiple years. I am creating a scatter plot but the measure only displays the last year of results, instead of the result for each year. Even when using a visualization filter, results are not shown for 2019, only 2020. How do I display the measure results spread out for each year in a scatter plot?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Thank you for taking the time to help me with my beginner questions.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 15:43:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1160536#M17788</guid>
      <dc:creator>JustinShultz</dc:creator>
      <dc:date>2020-06-15T15:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average Based on Multiple Critera and Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1160560#M17791</link>
      <description>&lt;P&gt;1. yes, CALCULATE() and many other functions accept multiple filters that are ANDed together. You can als use &amp;amp;&amp;amp;, || and IN for more elaborate filters (at a storage engine performance cost).&amp;nbsp; Check the documentation for detailed syntax.&lt;/P&gt;&lt;P&gt;2. "it depends" - do you want the year as an attribute in the scatter, or do you want to ignore it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 15:57:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1160560#M17791</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2020-06-15T15:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average Based on Multiple Critera and Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1160585#M17794</link>
      <description>&lt;P&gt;2. I would like the year as an attribute. I would like to display the results for the measure based on the results of year [Reporting Year]. So the % of Year measure is on the Y-axis and Reporting Year is on the X-axis.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 16:11:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1160585#M17794</guid>
      <dc:creator>JustinShultz</dc:creator>
      <dc:date>2020-06-15T16:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average Based on Multiple Critera and Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1160617#M17795</link>
      <description>&lt;P&gt;That would give you a scatter plot with vertical columns of dots for each year. Are you sure you want that?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 16:34:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1160617#M17795</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2020-06-15T16:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average Based on Multiple Critera and Filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1160633#M17800</link>
      <description>&lt;P&gt;I believe I mis-understand then. Below are two images of what I'm working with.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first is close to what I want but the orange dot is the measure we created, notice it's only on 2021.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second graphic is the measure on a scatter plot by itself.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 16:58:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Weighted-Average-Based-on-Multiple-Critera-and-Filters/m-p/1160633#M17800</guid>
      <dc:creator>JustinShultz</dc:creator>
      <dc:date>2020-06-15T16:58:48Z</dc:date>
    </item>
  </channel>
</rss>

