<?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: Measure Returning in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-Returning/m-p/3238565#M119099</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="561510" data-lia-user-login="BobMcC" class="lia-mention lia-mention-user"&gt;BobMcC&lt;/a&gt;&amp;nbsp;You could achieve the same in one measure using VAR's:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;WA LTV Locked All = 
  IF(
    SUM('dmLoanInfo'[LoanAmount]) &amp;gt; 0 ,
        VAR __1 = SUMX('dmLoanInfo',[LTV]*[LoanAmount])
        VAR __2 = SUM('dmLoanInfo'[LoanAmount])
        VAR __3 = __1 / __2
      RETURN
        __3,
      BLANK()
  )&lt;/LI-CODE&gt;
&lt;P&gt;The difference is that you are dividing your numerator once versus in the original, you are dividing the numerator by the demoninator for each row and then summing all up.&lt;/P&gt;</description>
    <pubDate>Tue, 16 May 2023 17:48:58 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2023-05-16T17:48:58Z</dc:date>
    <item>
      <title>Measure Returning</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-Returning/m-p/3238535#M119096</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've been trying to proof out a .pbix.&amp;nbsp; I'm having an issue with one of the measures.&lt;/P&gt;&lt;P&gt;The measure name is&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;STRONG&gt;WA LTV Locked All&lt;/STRONG&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'dmLoanInfo'&lt;/SPAN&gt;&lt;SPAN&gt;[LoanAmount]&lt;/SPAN&gt;&lt;SPAN&gt;) &amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt; ,&lt;/SPAN&gt;&lt;SPAN&gt;SUMX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'dmLoanInfo'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;[LTV]&lt;/SPAN&gt;&lt;SPAN&gt;*&lt;/SPAN&gt;&lt;SPAN&gt;[LoanAmount]&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'dmLoanInfo'&lt;/SPAN&gt;&lt;SPAN&gt;[LoanAmount]&lt;/SPAN&gt;&lt;SPAN&gt;)) / &lt;/SPAN&gt;&lt;SPAN&gt;100&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;BLANK&lt;/SPAN&gt;&lt;SPAN&gt;())&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I created an SQL script that returns different values than the measure.&amp;nbsp; Additionally, I exported the drill down data and ran the calculatiions in a spreadsheet... getting the same values that SQL is returning.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;The ONLY way, I could get the .pbix to return the same values I was getting from both Excel and SQL was to split the original measure into separate measures.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;UL&gt;&lt;LI&gt;Create Measure:&amp;nbsp; &lt;STRONG&gt;LTV*LoanAmount&lt;/STRONG&gt; = SUMX('dmLoanInfo',[LTV]*[LoanAmount])&lt;/LI&gt;&lt;LI&gt;Create Measure: &lt;STRONG&gt;SumOfLoanAmount&lt;/STRONG&gt; = sum(dmLoanInfo[LoanAmount])&lt;/LI&gt;&lt;LI&gt;Create Measure: &lt;STRONG&gt;WA LTV MinLogic2&lt;/STRONG&gt; = [LTV*LoanAmount] / [SumOfLoanAmount]&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Using the WA LTV MinLogic2 Measure I see the same values seen while proofing via Excel &amp;amp; SQL.&lt;/P&gt;&lt;P&gt;Trying to understand the difference in logic being applied - Original Measure VS New one using 2 new broken out measures&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This link is to a bare bones version of the .pbix with the relevant tables and measures involved:&amp;nbsp;&amp;nbsp;&lt;A href="https://drive.google.com/file/d/1_w01kt7uQVoCQ0UTf2tMiOxZamAzWosU/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/1_w01kt7uQVoCQ0UTf2tMiOxZamAzWosU/view?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help understanding this is GREATLY appreciated,&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;..bob&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 16 May 2023 17:24:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-Returning/m-p/3238535#M119096</guid>
      <dc:creator>BobMcC</dc:creator>
      <dc:date>2023-05-16T17:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: Measure Returning</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-Returning/m-p/3238565#M119099</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="561510" data-lia-user-login="BobMcC" class="lia-mention lia-mention-user"&gt;BobMcC&lt;/a&gt;&amp;nbsp;You could achieve the same in one measure using VAR's:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;WA LTV Locked All = 
  IF(
    SUM('dmLoanInfo'[LoanAmount]) &amp;gt; 0 ,
        VAR __1 = SUMX('dmLoanInfo',[LTV]*[LoanAmount])
        VAR __2 = SUM('dmLoanInfo'[LoanAmount])
        VAR __3 = __1 / __2
      RETURN
        __3,
      BLANK()
  )&lt;/LI-CODE&gt;
&lt;P&gt;The difference is that you are dividing your numerator once versus in the original, you are dividing the numerator by the demoninator for each row and then summing all up.&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 17:48:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-Returning/m-p/3238565#M119099</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-05-16T17:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Measure Returning</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-Returning/m-p/3238606#M119104</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi Greg,&lt;/P&gt;&lt;P&gt;Thanks for the quick reply!&amp;nbsp; &amp;nbsp;I am unable to duplicate the results from the original version in SQL.&amp;nbsp; Nor can I output the drill down detail and arrive at the same result in a spreadsheet.&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.google.com/spreadsheets/d/11YpK6CVuATibrwpIz1fwCdocUlWWeKkN/edit?usp=sharing&amp;amp;ouid=104714542534674252376&amp;amp;rtpof=true&amp;amp;sd=true" target="_blank"&gt;https://docs.google.com/spreadsheets/d/11YpK6CVuATibrwpIz1fwCdocUlWWeKkN/edit?usp=sharing&amp;amp;ouid=104714542534674252376&amp;amp;rtpof=true&amp;amp;sd=true&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Everthing proofs out to what is coming back from the new measure ( &lt;EM&gt;using the other 2 new measures&lt;/EM&gt; )&lt;/P&gt;&lt;P&gt;I guess my question boils down to this... Is the original measure correct for Weighted Average and if so, How can this be written in SQL?&amp;nbsp; The attached link has the spreadsheet I was using to work through this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Breaking out the LTV * LoanAmount Line by line and Totaling,&lt;/P&gt;&lt;P&gt;then taking that TOTAL and dividing by LoanAmount TOTAL returns the results from the 2nd measure as well as my SQL Query results.&amp;nbsp; Thanks for the help on this Greg!&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 18:20:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-Returning/m-p/3238606#M119104</guid>
      <dc:creator>BobMcC</dc:creator>
      <dc:date>2023-05-16T18:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: Measure Returning</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-Returning/m-p/3238620#M119105</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="561510" data-lia-user-login="BobMcC" class="lia-mention lia-mention-user"&gt;BobMcC&lt;/a&gt;&amp;nbsp;This is my best understanding of how to create a Weighted Average.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Better-Weighted-Average-per-Category/m-p/2805460#M895" target="_blank"&gt;Better Weighted Average per Category - Microsoft Power BI Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;div data-video-id="https://youtu.be/jlPTnELGbPg" data-video-remote-vid="https://youtu.be/jlPTnELGbPg" class="lia-video-container lia-media-is-center lia-media-size-medium"&gt;&lt;iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FjlPTnELGbPg%3Ffeature%3Doembed&amp;amp;display_name=YouTube&amp;amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DjlPTnELGbPg&amp;amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FjlPTnELGbPg%2Fhqdefault.jpg&amp;amp;type=text%2Fhtml&amp;amp;schema=youtube" allowfullscreen="" style="max-width: 100%"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 18:29:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-Returning/m-p/3238620#M119105</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-05-16T18:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Measure Returning</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-Returning/m-p/3238648#M119106</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the link Greg.&amp;nbsp; Just watched the clip.&amp;nbsp; Ultimately, it looks like your original post&lt;/P&gt;&lt;P&gt;aligns with his version of the Better Weighted Average Per Category&lt;img /&gt;&lt;/P&gt;&lt;PRE&gt;WA LTV Locked All = 
  IF(
    SUM('dmLoanInfo'[LoanAmount]) &amp;gt; 0 ,
        VAR __1 = SUMX('dmLoanInfo',[LTV]*[LoanAmount])
        VAR __2 = SUM('dmLoanInfo'[LoanAmount])
        VAR __3 = __1 / __2
      RETURN
        __3,
      BLANK()
  )&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;If that is the case, would you agree that the original measure is incorrect and should be changed to the version you sent?&amp;nbsp; Not asking you to make a ruling &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; just asking for your opinion.&amp;nbsp; Thanks!&lt;/P&gt;&lt;P&gt;btw:&amp;nbsp; I did vote for the idea per your tag line link.&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 18:54:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-Returning/m-p/3238648#M119106</guid>
      <dc:creator>BobMcC</dc:creator>
      <dc:date>2023-05-16T18:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: Measure Returning</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-Returning/m-p/3238740#M119112</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="561510" data-lia-user-login="BobMcC" class="lia-mention lia-mention-user"&gt;BobMcC&lt;/a&gt;&amp;nbsp;That would be my opinion, yes.&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 19:46:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-Returning/m-p/3238740#M119112</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-05-16T19:46:37Z</dc:date>
    </item>
  </channel>
</rss>

