<?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: stand-alone measure giving improper calculations in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/stand-alone-measure-giving-improper-calculations/m-p/4121637#M163655</link>
    <description>&lt;LI-CODE lang="markup"&gt;Is there any way to move or create my stand alone meaure as a table&lt;/LI-CODE&gt;
&lt;P&gt;only temporarily - table variables can be part of the measure calculation. But the final result of the measure must be a scalar value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider using EVALUATEANDLOG to examine the intermediate steps and find where you go off track.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Aug 2024 00:56:27 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2024-08-28T00:56:27Z</dc:date>
    <item>
      <title>stand-alone measure giving improper calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/stand-alone-measure-giving-improper-calculations/m-p/4121406#M163638</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have been scratching my head for days and looking for information that shed light of for the issues I am facing.&amp;nbsp;&lt;SPAN&gt;For further clarification this information is related to a construction project schedule.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Issue 1: Improper Calculation&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;I have the following stand alone measures that calculates the following values from a table range of data&lt;/P&gt;&lt;DIV&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Start&lt;/SPAN&gt;&lt;SPAN&gt; Dat :=&lt;/SPAN&gt; &lt;SPAN&gt;MIN&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'DCMA Summary'&lt;/SPAN&gt;&lt;SPAN&gt;[Start]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;- Finds the minimum date from all the rows from the different activities' start dates&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Finish Dat :=&lt;/SPAN&gt; &lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'DCMA Summary'&lt;/SPAN&gt;&lt;SPAN&gt;[Finish]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;- Finds the max date from all the rows from the different activities' finish dates&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I used a 3rd measure to find the project Duration&lt;/SPAN&gt;&lt;/DIV&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Project Duration :=&lt;/SPAN&gt; &lt;SPAN&gt;NETWORKDAYS&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Start Dat]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;[Finish Dat]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;ALLSELECTED&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Holidays&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;&lt;EM&gt;&lt;U&gt;When I try and create a Calculated Column Measure&lt;/U&gt;&lt;/EM&gt; that checks whether individual rows containting Original Duration satisfies the following expression, it doesn't calculate properly (original duration divide by project duration is more that 0.1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Level of Detail = DIVIDE('DCMA Summary'[Original Duration],[Project Duration])&amp;gt;0.1&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;i.e in some cases if the original duratio is 11 divided by project duration of 97 it &lt;U&gt;&lt;STRONG&gt;correctly&lt;/STRONG&gt;&lt;/U&gt; calculates as 0.11 =&amp;nbsp; True. But with lower values like an original duration of 3, it &lt;U&gt;&lt;STRONG&gt;incorrectly&lt;/STRONG&gt;&lt;/U&gt; calculates 3/97 = 1 =True.&amp;nbsp; (Note: I removed the '&amp;gt;0.1' in an attempt to troubleshoot). It is &lt;U&gt;&lt;STRONG&gt;correct&lt;/STRONG&gt;&lt;/U&gt; for Original duratio of 0/97 = 0 = False&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could you please help me fix this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Issue 2: Filtering Data using a Standalone Measure&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I was able to create several meaures that calculate the different quarters within the project duration. Some were a build up of the measures above.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Q1 &lt;/SPAN&gt;&lt;SPAN&gt;Start&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt; &lt;SPAN&gt;[Start Dat]&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;Q1 Finish = &lt;SPAN&gt;[Q1 Start]&lt;/SPAN&gt;&lt;SPAN&gt;+((&lt;/SPAN&gt;&lt;SPAN&gt;[Finish Dat]&lt;/SPAN&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;[Start Dat]&lt;/SPAN&gt;&lt;SPAN&gt;)/&lt;/SPAN&gt;&lt;SPAN&gt;4&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Q1 Duration =&lt;/SPAN&gt; &lt;SPAN&gt;NETWORKDAYS&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Q1 Start]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;[Q1 Finish]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;ALLSELECTED&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Holidays&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;I have data for several projects that was imported into power BI. Each project has a unique Project ID with various activities. Within my report interface I use a filter to show one project at a time. I am trying to tag all the activities regardless of project with a dynamic identifier of which Quarter it belongs to (Q1, Q2, Q3,Q4) but when I use the formula below in the &lt;STRONG&gt;table view&lt;/STRONG&gt;, I get the error below&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Q1 Identifier =&lt;/SPAN&gt; &lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'DCMA Summary'&lt;/SPAN&gt;&lt;SPAN&gt;[Finish]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;=&lt;/SPAN&gt;&lt;SPAN&gt;[Q1 Finish]&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Q1"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;P&gt;&lt;EM&gt;A circular dependency was detected: DCMA Summary[Level of Detail], DCMA Summary[Q1 Identifier], DCMA Summary[Level of Detail].&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;How can I dynamically create an expression that is able to tag the correct Quarter to, each activity undertaken at different points for all the different projects in my data base?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Issue 3: Stand alone Formula conversion into a table&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Is there any way to move or create my stand alone meaure as a table, since some filter functions are only able to filter data that is within a table. Or is there a way to express the syntax in a way that makes the DAX formula select the meaure as the entity to filter by? I would like to filter data by the different quarters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 19:35:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/stand-alone-measure-giving-improper-calculations/m-p/4121406#M163638</guid>
      <dc:creator>DK_Bee</dc:creator>
      <dc:date>2024-08-27T19:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: stand-alone measure giving improper calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/stand-alone-measure-giving-improper-calculations/m-p/4121637#M163655</link>
      <description>&lt;LI-CODE lang="markup"&gt;Is there any way to move or create my stand alone meaure as a table&lt;/LI-CODE&gt;
&lt;P&gt;only temporarily - table variables can be part of the measure calculation. But the final result of the measure must be a scalar value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider using EVALUATEANDLOG to examine the intermediate steps and find where you go off track.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 00:56:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/stand-alone-measure-giving-improper-calculations/m-p/4121637#M163655</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-08-28T00:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: stand-alone measure giving improper calculations</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/stand-alone-measure-giving-improper-calculations/m-p/4126073#M163854</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="795699" data-lia-user-login="DK_Bee" class="lia-mention lia-mention-user"&gt;DK_Bee&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my solution, hope it helps.&amp;nbsp;Please refer to the uploaded pbix file for full details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Issue 1: Improper Calculation&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Change your “Project Duration” and "Level of Detail" measures with the following DAX:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Project Duration = 
CALCULATE(
    NETWORKDAYS(
        MIN('DCMA Summary'[Start]),
        MAX('DCMA Summary'[Finish]),
        1,
        ALLSELECTED(Holidays[Date])
    )
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Level of Detail = 
DIVIDE(
    'DCMA Summary'[Original Duration],
    CALCULATE(
        [Project Duration],
        REMOVEFILTERS('DCMA Summary'[Quarter Identifier]),
        ALLSELECTED('DCMA Summary'[Activity ID])
    )
) &amp;gt; 0.1&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Issue 2: Filtering Data using a Standalone Measure&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;1. Create a new table with the following DAX:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Quarters = 
SELECTCOLUMNS(
    CROSSJOIN(
        VALUES('DCMA Summary'[Project]),
        {"Q1", "Q2", "Q3", "Q4"}
    ),
    "Project", [Project],
    "Quarter", [Value],
    "Start Date", 
            VAR ProjectStart = CALCULATE(MIN('DCMA Summary'[Start]), ALLEXCEPT('DCMA Summary', 'DCMA Summary'[Project]))
            RETURN ProjectStart,
        "Finish Date", 
            VAR ProjectFinish = CALCULATE(MAX('DCMA Summary'[Finish]), ALLEXCEPT('DCMA Summary', 'DCMA Summary'[Project]))
            RETURN ProjectFinish
)&lt;/LI-CODE&gt;
&lt;P&gt;2. Create a new column in the new table to calculate each quarter finish date&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Quarter Finish Date = 
VAR StartDate = Quarters[Start Date]
VAR FinishDate = Quarters[Finish Date]
VAR Q1Finish = StartDate + (FinishDate - StartDate) / 4
VAR Q2Finish = Q1Finish + 1 + (FinishDate - StartDate) / 4
VAR Q3Finish = Q2Finish + 1 + (FinishDate - StartDate) / 4
VAR Q4Finish = FinishDate
RETURN
    SWITCH(
        'Quarters'[Quarter],
        "Q1", Q1Finish,
        "Q2", Q2Finish,
        "Q3", Q3Finish,
        "Q4", Q4Finish
    )&lt;/LI-CODE&gt;
&lt;P&gt;3.&amp;nbsp;Use the LOOKUPVALUE() function to create a new column “Quarter Identifier” in the “DCMA Summary” table.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Quarter Identifier = 
VAR Q1Finish = LOOKUPVALUE('Quarters'[Quarter Finish Date], 'Quarters'[Quarter], "Q1", 'Quarters'[Project], 'DCMA Summary'[Project])
VAR Q2Finish = LOOKUPVALUE('Quarters'[Quarter Finish Date], 'Quarters'[Quarter], "Q2", 'Quarters'[Project], 'DCMA Summary'[Project])
VAR Q3Finish = LOOKUPVALUE('Quarters'[Quarter Finish Date], 'Quarters'[Quarter], "Q3", 'Quarters'[Project], 'DCMA Summary'[Project])
VAR Q4Finish = LOOKUPVALUE('Quarters'[Quarter Finish Date], 'Quarters'[Quarter], "Q4", 'Quarters'[Project], 'DCMA Summary'[Project])
RETURN
    SWITCH(
        TRUE(),
        'DCMA Summary'[Finish] &amp;lt;= Q1Finish, "Q1",
        'DCMA Summary'[Finish] &amp;lt;= Q2Finish, "Q2",
        'DCMA Summary'[Finish] &amp;lt;= Q3Finish, "Q3",
        'DCMA Summary'[Finish] &amp;lt;= Q4Finish, "Q4",
        "Unknown"
    )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Issue 3: Stand alone Formula conversion into a table&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;The calculated column “Quarter Identifier” has been created in the above step and you can use this field to create quarter slicers.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Jarvis Tang&lt;BR /&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 02:56:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/stand-alone-measure-giving-improper-calculations/m-p/4126073#M163854</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-30T02:56:59Z</dc:date>
    </item>
  </channel>
</rss>

