<?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: Wrong total? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wrong-total/m-p/3351703#M125865</link>
    <description>&lt;P&gt;Ok, so how cool is ChatGPT!&amp;nbsp; After 2 hours of no replies but 28 views I thought I'd give the AI a test, and it gave me the solution in seconds!!&amp;nbsp; Feel free to critique but it worked for me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the AI response to the exact same question:&lt;/P&gt;&lt;P&gt;To calculate the cost per person per project per period correctly, you need to use a measure that considers the aggregation at the appropriate levels. In this case, you need to calculate the cost for each allocation (staff member to project in a given period) and then aggregate those individual allocation costs correctly.&lt;/P&gt;&lt;P&gt;To do this, you can use an iterator function like SUMX to iterate over each allocation and calculate the cost for that specific allocation. Here's how you can write the measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;CostPerAllocation = SUMX ( Allocations, Allocations[Days] * LOOKUPVALUE(Resources[Rate], Resources[Staff], Allocations[Staff]) )&lt;P&gt;Let's break down the measure:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;SUMX: This is the iterator function that iterates over each row in the Allocations table.&lt;/LI&gt;&lt;LI&gt;Allocations[Days]: This retrieves the number of days from the current row of the Allocations table.&lt;/LI&gt;&lt;LI&gt;LOOKUPVALUE: This function looks up the corresponding rate from the Resources table based on the Staff member in the current row of the Allocations table.&lt;/LI&gt;&lt;LI&gt;Allocations[Staff]: This provides the Staff member from the current row of the Allocations table to the LOOKUPVALUE function.&lt;P&gt;The measure calculates the cost for each individual allocation (Staff member to project in a given period) and then you can use this measure to correctly calculate the total cost per person per project per period.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 26 Jul 2023 18:09:39 GMT</pubDate>
    <dc:creator>IntaBruce</dc:creator>
    <dc:date>2023-07-26T18:09:39Z</dc:date>
    <item>
      <title>Wrong total?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wrong-total/m-p/3351489#M125856</link>
      <description>&lt;P&gt;I have a table of staff which contains their day rates and a table of allocations which contains numbers of days for a given staff member to a given project in a given period.&lt;BR /&gt;I want a measure that will calculate the cost per person per project per period so I can display it in a table&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;sum&lt;/SPAN&gt;&lt;SPAN&gt;(Allocations[Days]) * &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(Resources[Rate]) works fine at the resource line level but the total is incorrect for all resources.&amp;nbsp; I think this is because this measure is summing the rates for all resources before multipling by the number of days, instaed of adding up all the line leve values.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Does that make sense?&amp;nbsp; And how do I write a measure to fix it?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 26 Jul 2023 15:42:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wrong-total/m-p/3351489#M125856</guid>
      <dc:creator>IntaBruce</dc:creator>
      <dc:date>2023-07-26T15:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong total?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wrong-total/m-p/3351703#M125865</link>
      <description>&lt;P&gt;Ok, so how cool is ChatGPT!&amp;nbsp; After 2 hours of no replies but 28 views I thought I'd give the AI a test, and it gave me the solution in seconds!!&amp;nbsp; Feel free to critique but it worked for me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the AI response to the exact same question:&lt;/P&gt;&lt;P&gt;To calculate the cost per person per project per period correctly, you need to use a measure that considers the aggregation at the appropriate levels. In this case, you need to calculate the cost for each allocation (staff member to project in a given period) and then aggregate those individual allocation costs correctly.&lt;/P&gt;&lt;P&gt;To do this, you can use an iterator function like SUMX to iterate over each allocation and calculate the cost for that specific allocation. Here's how you can write the measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;CostPerAllocation = SUMX ( Allocations, Allocations[Days] * LOOKUPVALUE(Resources[Rate], Resources[Staff], Allocations[Staff]) )&lt;P&gt;Let's break down the measure:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;SUMX: This is the iterator function that iterates over each row in the Allocations table.&lt;/LI&gt;&lt;LI&gt;Allocations[Days]: This retrieves the number of days from the current row of the Allocations table.&lt;/LI&gt;&lt;LI&gt;LOOKUPVALUE: This function looks up the corresponding rate from the Resources table based on the Staff member in the current row of the Allocations table.&lt;/LI&gt;&lt;LI&gt;Allocations[Staff]: This provides the Staff member from the current row of the Allocations table to the LOOKUPVALUE function.&lt;P&gt;The measure calculates the cost for each individual allocation (Staff member to project in a given period) and then you can use this measure to correctly calculate the total cost per person per project per period.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 26 Jul 2023 18:09:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wrong-total/m-p/3351703#M125865</guid>
      <dc:creator>IntaBruce</dc:creator>
      <dc:date>2023-07-26T18:09:39Z</dc:date>
    </item>
  </channel>
</rss>

