<?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: Trouble Calculating the Date Difference between two fields that are the same, but different values in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3233020#M118697</link>
    <description>&lt;P&gt;I like this!&amp;nbsp; I hadn't thought of it before.&amp;nbsp; Oddly enough, it didn't give me results in the SignFinalCommitment column until I added "||&amp;nbsp;&lt;SPAN&gt;'SPSTask'[Task Name] = &lt;/SPAN&gt;&lt;SPAN&gt;"Review and Sign Final Commitment".&amp;nbsp; I could live with that if I had to.&lt;BR /&gt;But, when I add that to the measure, I still don't get any results.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 12 May 2023 14:30:13 GMT</pubDate>
    <dc:creator>kkirner</dc:creator>
    <dc:date>2023-05-12T14:30:13Z</dc:date>
    <item>
      <title>Trouble Calculating the Date Difference between two fields that are the same, but different values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3231025#M118559</link>
      <description>&lt;P&gt;Good morning!&amp;nbsp; I'm relatively new to Power BI.&amp;nbsp; I have a decent understanding of DAX, but have always struggled with the Date/Time calculations.&lt;BR /&gt;I have a report with multiple tables, but I think what's important to this question is the Task and Order tables.&amp;nbsp; Here's how they relate to each other.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The order table contains data for each file we work on, like order number, property address, buyer/seller names, etc.&amp;nbsp; The task table contains a variety of tasks that need to be done to complete the file.&amp;nbsp; Each task has a unique name and lookup code, multiple statuses, a created date, a requested date and a received/completed date.&amp;nbsp; I'm trying to calculate the DATEDIFF between the&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;SPSTask[Completed/Received Date] for two different tasks.&amp;nbsp; For instance when the TitleWork task was received to the Sign Final Commitment received date.&lt;BR /&gt;This is an example of how the data output would look (this screenshot is measuring the Requested Date to the Received Date for one (or the same) task.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;img /&gt;&lt;P&gt;Here's my DAX Measure - I receive an error "Multiple columns cannot be converted to a scalar value".&amp;nbsp; I've tried reworking it several ways and haven't had any success.&amp;nbsp; My thought process was to define the two tasks involved, then if it was those tasks involved use the completed/received date for them and calculate the datediff.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd appreciate any help provided.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;TitleRec'd to SgnFnlComm TAT =&lt;BR /&gt;var TWTaskDefined = SUMX(VALUES(SPSTask[Task Name]),FILTER(SPSTask,SPSTask[TaskLookupCode]="TitleWork"))&lt;BR /&gt;var CommitTaskDefined = SUMX(VALUES(SPSTask[Task Name]),FILTER(SPSTask,SPSTask[TaskLookupCode]="SgnFnlCom"))&lt;BR /&gt;var TWTaskRecdDate = If(TWTaskDefined="True", Values(SPSTask[Completed/Received Date]))&lt;BR /&gt;var CommitTaskRecdDate = IF(CommitTaskDefined="True",VALUES(SPSTask[Completed/Received Date]))&lt;BR /&gt;var DayCalcTWCommit = DATEDIFF(TWTaskRecdDate,CommitTaskRecdDate,DAY)&lt;BR /&gt;return DayCalcTWCommit&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 11 May 2023 14:24:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3231025#M118559</guid>
      <dc:creator>kkirner</dc:creator>
      <dc:date>2023-05-11T14:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Calculating the Date Difference between two fields that are the same, but different values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3231254#M118574</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Days Diff Title Work to Sign Final Commitment =
SUMX (
    VALUES ( 'SPSOrder'[Order ID] ),
    VAR TitleWork =
        CALCULATE (
            MAX ( 'SPSTask'[Completed/Received Date] ),
            'SPSTask'[TaskLookupCode] = "TitleWork"
        )
    VAR SignFinalCommitment =
        CALCULATE (
            MAX ( 'SPSTask'[Completed/Received Date] ),
            'SPSTask'[TaskLookupCode] = "SgnFnlCom"
        )
    VAR Result =
        DATEDIFF ( TitleWork, SignFinalCommitment, DAY )
    RETURN
        Result
)
&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 11 May 2023 15:54:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3231254#M118574</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-05-11T15:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Calculating the Date Difference between two fields that are the same, but different values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3232651#M118675</link>
      <description>&lt;P&gt;I actually did reply to this answer, but for some reason it didn't post here.&amp;nbsp; This solution allowed my measure to save without error.&amp;nbsp; However, I don't get any results with it.&amp;nbsp; I checked my dataset, using three of the files from the data output screenshot above and there is data for both received/completed tasks that I'm trying to measure.&lt;BR /&gt;Unsure what to do next.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 11:53:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3232651#M118675</guid>
      <dc:creator>kkirner</dc:creator>
      <dc:date>2023-05-12T11:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Calculating the Date Difference between two fields that are the same, but different values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3232718#M118680</link>
      <description>&lt;P&gt;Try creating a calculated table like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Tmp Table =
ADDCOLUMNS (
    VALUES ( 'SPSOrder'[Order ID] ),
    "TitleWork",
        CALCULATE (
            MAX ( 'SPSTask'[Completed/Received Date] ),
            'SPSTask'[TaskLookupCode] = "TitleWork"
        ),
    "SignFinalCommitment",
        CALCULATE (
            MAX ( 'SPSTask'[Completed/Received Date] ),
            'SPSTask'[TaskLookupCode] = "SgnFnlCom"
        )
)
&lt;/LI-CODE&gt;
&lt;P&gt;You could then have a look in the data view and see if that gives any insights&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 12:37:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3232718#M118680</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-05-12T12:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Calculating the Date Difference between two fields that are the same, but different values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3233020#M118697</link>
      <description>&lt;P&gt;I like this!&amp;nbsp; I hadn't thought of it before.&amp;nbsp; Oddly enough, it didn't give me results in the SignFinalCommitment column until I added "||&amp;nbsp;&lt;SPAN&gt;'SPSTask'[Task Name] = &lt;/SPAN&gt;&lt;SPAN&gt;"Review and Sign Final Commitment".&amp;nbsp; I could live with that if I had to.&lt;BR /&gt;But, when I add that to the measure, I still don't get any results.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 14:30:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3233020#M118697</guid>
      <dc:creator>kkirner</dc:creator>
      <dc:date>2023-05-12T14:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Calculating the Date Difference between two fields that are the same, but different values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3233036#M118699</link>
      <description>&lt;P&gt;johnt75 - thank you.&amp;nbsp; This is the one that didn't error out, but also didn't give any results.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 14:38:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3233036#M118699</guid>
      <dc:creator>kkirner</dc:creator>
      <dc:date>2023-05-12T14:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Calculating the Date Difference between two fields that are the same, but different values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3233053#M118701</link>
      <description>&lt;P&gt;Are there any other columns in the visual which could be affecting things? The results in the calculated table and the measure should be identical.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 14:44:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3233053#M118701</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-05-12T14:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Calculating the Date Difference between two fields that are the same, but different values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3233083#M118703</link>
      <description>&lt;P&gt;johnt75 Thank you!&amp;nbsp; You nailed it.&amp;nbsp; I removed all of the columns other than the Order ID and got the DateDiff results.&amp;nbsp; I appreciate all of your help!&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 15:01:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3233083#M118703</guid>
      <dc:creator>kkirner</dc:creator>
      <dc:date>2023-05-12T15:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble Calculating the Date Difference between two fields that are the same, but different values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3233098#M118704</link>
      <description>&lt;P&gt;If you need to put them back in the visual you could add REMOVEFILTERS clauses for those columns into the CALCULATE calls.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 15:06:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Trouble-Calculating-the-Date-Difference-between-two-fields-that/m-p/3233098#M118704</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-05-12T15:06:15Z</dc:date>
    </item>
  </channel>
</rss>

