<?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: Calculating forecasting values. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-forecasting-values/m-p/4250675#M168293</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="241995" data-lia-user-login="kalspiros" class="lia-mention lia-mention-user"&gt;kalspiros&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get correct sum, you need to replace&amp;nbsp; the "max" functions to "sum" function whenever applicable based on the operations you are performing in each variables. review all the calculate expressions and modify to ge the righr total.&amp;nbsp;&lt;BR /&gt;Else share sample data.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Oct 2024 11:18:26 GMT</pubDate>
    <dc:creator>Rupak_bi</dc:creator>
    <dc:date>2024-10-21T11:18:26Z</dc:date>
    <item>
      <title>Calculating forecasting values.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-forecasting-values/m-p/4250512#M168287</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a measure that works all great.&lt;/P&gt;&lt;P&gt;The measure takes the deadline of projects and based on this, it calculates the number of working days and multiplying with the hourly rate of the employee and the expected working hours per week.&lt;/P&gt;&lt;P&gt;Here it is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=-- Today, brought forward from Power Query
VAR filteredMin =
    MIN('Calendar'[Date])
-- Set by the client, forecasting period
VAR filteredMax =
    MAX('Calendar'[Date])
-- Deadline of Project
VAR deadlineProject = 
    MAX(Quote_Items[Deadline])
-- Repeating deadline of Project in all months.
VAR deadlineWhole =
    CALCULATE(
        MAX(Quote_Items[Deadline]),
    ALL('Calendar'))
-- Calculation of accurate date to be used to calculate working days.
VAR deadlineMonth =
    IF(
        ISBLANK(deadlineProject),IF(
            deadlineWhole &amp;lt; filteredMax,BLANK(),filteredMax),
        deadlineProject)
-- Filter the 'Calendar' table to include only working days between filteredMin and deadlineMonth
VAR workingDaysCount = 
    COUNTROWS(
        FILTER(
            'Calendar',
            'Calendar'[Date] &amp;gt;= filteredMin &amp;amp;&amp;amp;
            'Calendar'[Date] &amp;lt;= deadlineMonth &amp;amp;&amp;amp;
            WEEKDAY('Calendar'[Date], 2) &amp;lt;= 5  -- Weekday function, with 2 means Monday = 1, Sunday = 7. Excludes weekends
        )
    )
-- Returns the hours worked per week on that project
VAR maxHours =
    CALCULATE(MAX(Quote_Items[Hours per week]),ALL('Calendar'))
-- Returns the rate of the employee for this project
VAR rateOfEmployee =
    CALCULATE(MAX(Quote_Items[Rate]),ALL('Calendar'))
-- Final result, multiplying by the working days.
VAR result = 
    workingDaysCount * maxHours * rateOfEmployee

RETURN result&lt;/LI-CODE&gt;&lt;P&gt;The problem I'm facing is that&amp;nbsp;it doesn't calculate Totals correctly (which makes sense, I think i should SUMX each of the values).&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Any ideas on how I can change this measure to return the correct SUM?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 09:42:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-forecasting-values/m-p/4250512#M168287</guid>
      <dc:creator>kalspiros</dc:creator>
      <dc:date>2024-10-21T09:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating forecasting values.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-forecasting-values/m-p/4250675#M168293</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="241995" data-lia-user-login="kalspiros" class="lia-mention lia-mention-user"&gt;kalspiros&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get correct sum, you need to replace&amp;nbsp; the "max" functions to "sum" function whenever applicable based on the operations you are performing in each variables. review all the calculate expressions and modify to ge the righr total.&amp;nbsp;&lt;BR /&gt;Else share sample data.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 11:18:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-forecasting-values/m-p/4250675#M168293</guid>
      <dc:creator>Rupak_bi</dc:creator>
      <dc:date>2024-10-21T11:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating forecasting values.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-forecasting-values/m-p/4250823#M168301</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="583487" data-lia-user-login="Rupak_bi" class="lia-mention lia-mention-user"&gt;Rupak_bi&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your message. Actually 'sum' won't do the cut I'm afraid.&lt;/P&gt;&lt;P&gt;workingDaysCount is one of the culprits as it'll return an ubnormal count of days in the Grand Total.&lt;/P&gt;&lt;P&gt;Additionally, a sum of rateOfEmployees won't return the accurate number as it depends on how many hours each of the employee will work on each project.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find attached the file with some sample data and the measures (mainly interested on "Price")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: not sure how i can share sample file and couldn't find anything relevant here:&amp;nbsp;&lt;A href="https://community.fabric.microsoft.com/t5/Using-the-Community/tkb-p/fbc_using_the_community" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Using-the-Community/tkb-p/fbc_using_the_community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 13:10:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-forecasting-values/m-p/4250823#M168301</guid>
      <dc:creator>kalspiros</dc:creator>
      <dc:date>2024-10-21T13:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating forecasting values.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-forecasting-values/m-p/4251667#M168360</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="241995" data-lia-user-login="kalspiros" class="lia-mention lia-mention-user"&gt;kalspiros&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First of all thanks to&amp;nbsp;Rupak_bi&amp;nbsp; for the quick reply. I have some other thoughts to add:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;You can create a new measure to be placed on the visual object instead of the original measure, totaling the correct display.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;New Measure = SUMX(VALUES('Table'[Deadline]),[Measure])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;If the above one can't help you get the desired result, please provide some&amp;nbsp;&lt;STRONG&gt;sample data.&amp;nbsp;It is better&amp;nbsp;if you can share a&amp;nbsp;simplified&amp;nbsp;pbix file.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Refer to:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-provide-sample-data-in-the-Power-BI-Forum%2Fba-p%2F963216&amp;amp;data=05%7C01%7Cv-jianboli%40microsoft.com%7Ca7ce12be0f454896a61208da8034281b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637963258750159993%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=orVyE0%2FImc2MEFUqXtCveK0uf33594f67ZDxb8ybuNI%3D&amp;amp;reserved=0" target="_blank" rel="noopener"&gt;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-Get-Your-Question-Answered-Quickly%2Fba-p%2F38490&amp;amp;data=05%7C01%7Cv-jianboli%40microsoft.com%7Ca7ce12be0f454896a61208da8034281b%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637963258750159993%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=XocTq9o6TjxbxJqTak20E3kKp7q5HxKTNZef7xESMV0%3D&amp;amp;reserved=0" target="_blank" rel="noopener"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;
&lt;P&gt;If this post  &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution &lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 02:12:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-forecasting-values/m-p/4251667#M168360</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-22T02:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating forecasting values.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-forecasting-values/m-p/4252581#M168421</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply and providing these helpful pages.&lt;/P&gt;&lt;P&gt;In all honesty, I'm working on Excel.&lt;/P&gt;&lt;P&gt;I have just recreated the model in PBI but my original measure does not work as expected.&lt;/P&gt;&lt;P&gt;Therefore, I'm providing link to both files and I'd be probably more interested on exploring the .xlsx instead.&lt;/P&gt;&lt;P&gt;Your measure didn't quite work as expected I'm afraid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please feel free having a look and let me know if there's anything more I can do to assist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://kompassbms.sharepoint.com/:u:/g/Ednr9zRJy1hLj3WcNjLSMCQBktFsahvcYZYiMNM5xA9yxg?e=VQa2oA" target="_blank"&gt;forecasting.pbix&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://kompassbms.sharepoint.com/:x:/g/ES1UMR6B2TtAihLO5mwDrUsBvx5tFVHoX23Hq2vEh5i_Lg?e=CUAq89" target="_blank"&gt;Forecasting_share.xlsx&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 12:34:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-forecasting-values/m-p/4252581#M168421</guid>
      <dc:creator>kalspiros</dc:creator>
      <dc:date>2024-10-22T12:34:30Z</dc:date>
    </item>
  </channel>
</rss>

