<?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: Calculate if order is too late or on time based on parameter in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-if-order-is-too-late-or-on-time-based-on-parameter/m-p/3776163#M147586</link>
    <description>&lt;P&gt;Thank you for answering my question. The reason for using related is that the table 'Indkøbsordrer' has the information about [Indkøbsbilagsart]. This information is not represented in the table 'Varemodtagelser'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote another DAX-formula which solved my problem.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Z_ForsinkedeBilagsarter = 
VAR Forsinkelser_ZLM_ZCD =
    CALCULATE (
        DISTINCTCOUNT ( 'Indkøbsordrer'[Indkøbsordrenummer] ),
        FILTER (
            'Varemodtagelser',
            (
                'Varemodtagelser'[Modtagelsesdato]
                - 'Leveringstidsjustering'[Leveringstidsjustering Value]
                - 'Varemodtagelser'[Statistikdato]
            ) &amp;gt; 0
                &amp;amp;&amp;amp; (
                    RELATED ( 'Indkøbsordrer'[Indkøbsbilagsart] ) = "ZLM"
                    || RELATED ( 'Indkøbsordrer'[Indkøbsbilagsart] ) = "ZCD"
                )
        )
    )
VAR Forsinkelser_Andre =
    CALCULATE (
        DISTINCTCOUNT ( 'Indkøbsordrer'[Indkøbsordrenummer] ),
        FILTER (
            'Varemodtagelser',
            (
                'Varemodtagelser'[Modtagelsesdato]
                - 5
                - 'Varemodtagelser'[Statistikdato]
            ) &amp;gt; 0
                &amp;amp;&amp;amp; NOT (
                    RELATED ( 'Indkøbsordrer'[Indkøbsbilagsart] ) = "ZLM"
                    || RELATED ( 'Indkøbsordrer'[Indkøbsbilagsart] ) = "ZCD"
                )
        )
    )
RETURN
    Forsinkelser_ZLM_ZCD + Forsinkelser_Andre&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 19 Mar 2024 19:14:37 GMT</pubDate>
    <dc:creator>RegionH</dc:creator>
    <dc:date>2024-03-19T19:14:37Z</dc:date>
    <item>
      <title>Calculate if order is too late or on time based on parameter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-if-order-is-too-late-or-on-time-based-on-parameter/m-p/3771918#M147362</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My datamodel has two tables called 'Indkøbsordrer' and 'Varemodtagelser'. The two tables are connected on [Ordre nøgle] in a one to many relationship.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to calculate if an order is "Too late" or "On time" based on the following DAX-formula.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Ordrer Punktlighed = 
if(
    ISEMPTY(
        Filter(
            CALCULATETABLE(
            'Varemodtagelser', ALLEXCEPT('Varemodtagelser','Varemodtagelser'[Indkøbsordrenummer])),
            sum(Varemodtagelser[Modtagelsesdato])-'Leveringstidsjustering'[Leveringstidsjustering Value]-sum(Varemodtagelser[Statistikdato]) &amp;gt; 0
        )
    ),
    "On time",
    "Late"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formula is working fine. But now I would like to distinguish between the value of the column 'Indkøbsordrer'[Indkøbsbilagsart].&amp;nbsp; If the value in the row is equal to "ZLM" or "ZCD, then use the parameter as is. But if the value is diffent, then use the value 5 days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I wrote this formula, but it is not working, because when I use this measure in another measure to calculate the sum of "Delayed orders" I get 2.484. The same result as the original formula.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Z_Ordrer_Punktlighed_Bilagsart = 
IF(
    ISEMPTY(
        FILTER(
            CALCULATETABLE(
                'Varemodtagelser',
                ALLEXCEPT('Varemodtagelser', 'Varemodtagelser'[Indkøbsordrenummer])
            ),
            SUM('Varemodtagelser'[Modtagelsesdato]) - 
            IF(
                RELATED('Indkøbsordrer'[Indkøbsbilagsart]) = "ZLM" || RELATED('Indkøbsordrer'[Indkøbsbilagsart]) = "ZCD",
                'Leveringstidsjustering'[Leveringstidsjustering Value],
                5
            ) - 
            SUM('Varemodtagelser'[Statistikdato]) &amp;gt; 0
        )
    ),
    "On time",
    "Late"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope someone will take a look at the formula and maybe help me correct it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Morten&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 14:15:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-if-order-is-too-late-or-on-time-based-on-parameter/m-p/3771918#M147362</guid>
      <dc:creator>RegionH</dc:creator>
      <dc:date>2024-03-18T14:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate if order is too late or on time based on parameter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-if-order-is-too-late-or-on-time-based-on-parameter/m-p/3772488#M147399</link>
      <description>&lt;P&gt;what's your reasoning for using RELATED in a measure?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Z_Ordrer_Punktlighed_Bilagsart = 
IF(
    ISEMPTY(
        FILTER(
            CALCULATETABLE(
                'Varemodtagelser',
                ALLEXCEPT('Varemodtagelser', 'Varemodtagelser'[Indkøbsordrenummer])
            ),
            SUM('Varemodtagelser'[Modtagelsesdato]) - 
            IF('Indkøbsordrer'[Indkøbsbilagsart]) IN { "ZLM" ,"ZCD" },
                'Leveringstidsjustering'[Leveringstidsjustering Value],5
            ) - 
            SUM('Varemodtagelser'[Statistikdato]) &amp;gt; 0
        )
    ),
    "On time",
    "Late"
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also use Countrows instead of IF(ISEMPTY).&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 19:14:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-if-order-is-too-late-or-on-time-based-on-parameter/m-p/3772488#M147399</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-03-18T19:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate if order is too late or on time based on parameter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-if-order-is-too-late-or-on-time-based-on-parameter/m-p/3776163#M147586</link>
      <description>&lt;P&gt;Thank you for answering my question. The reason for using related is that the table 'Indkøbsordrer' has the information about [Indkøbsbilagsart]. This information is not represented in the table 'Varemodtagelser'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote another DAX-formula which solved my problem.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Z_ForsinkedeBilagsarter = 
VAR Forsinkelser_ZLM_ZCD =
    CALCULATE (
        DISTINCTCOUNT ( 'Indkøbsordrer'[Indkøbsordrenummer] ),
        FILTER (
            'Varemodtagelser',
            (
                'Varemodtagelser'[Modtagelsesdato]
                - 'Leveringstidsjustering'[Leveringstidsjustering Value]
                - 'Varemodtagelser'[Statistikdato]
            ) &amp;gt; 0
                &amp;amp;&amp;amp; (
                    RELATED ( 'Indkøbsordrer'[Indkøbsbilagsart] ) = "ZLM"
                    || RELATED ( 'Indkøbsordrer'[Indkøbsbilagsart] ) = "ZCD"
                )
        )
    )
VAR Forsinkelser_Andre =
    CALCULATE (
        DISTINCTCOUNT ( 'Indkøbsordrer'[Indkøbsordrenummer] ),
        FILTER (
            'Varemodtagelser',
            (
                'Varemodtagelser'[Modtagelsesdato]
                - 5
                - 'Varemodtagelser'[Statistikdato]
            ) &amp;gt; 0
                &amp;amp;&amp;amp; NOT (
                    RELATED ( 'Indkøbsordrer'[Indkøbsbilagsart] ) = "ZLM"
                    || RELATED ( 'Indkøbsordrer'[Indkøbsbilagsart] ) = "ZCD"
                )
        )
    )
RETURN
    Forsinkelser_ZLM_ZCD + Forsinkelser_Andre&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 19 Mar 2024 19:14:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-if-order-is-too-late-or-on-time-based-on-parameter/m-p/3776163#M147586</guid>
      <dc:creator>RegionH</dc:creator>
      <dc:date>2024-03-19T19:14:37Z</dc:date>
    </item>
  </channel>
</rss>

