<?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: Getting the numbers of days between tow dates by name and get the average too in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-numbers-of-days-between-tow-dates-by-name-and-get/m-p/3455623#M131718</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="601623" data-lia-user-login="FARIDMD" class="lia-mention lia-mention-user"&gt;FARIDMD&lt;/a&gt;&amp;nbsp;, could you share a sample file?&lt;BR /&gt;&lt;BR /&gt;Do you want to calculate in a measure or column in the table will work?&lt;/P&gt;</description>
    <pubDate>Mon, 02 Oct 2023 07:44:30 GMT</pubDate>
    <dc:creator>gaurav-lakhotia</dc:creator>
    <dc:date>2023-10-02T07:44:30Z</dc:date>
    <item>
      <title>Getting the numbers of days between tow dates by name and get the average too</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-numbers-of-days-between-tow-dates-by-name-and-get/m-p/3455485#M131711</link>
      <description>&lt;P&gt;Hi, I need assistance from expert here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data of request item which include (Name, the date of the request)&amp;nbsp; &amp;nbsp;and want to find the number of days between each request by each name (cover in blue) and later find the average of the days different.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;Thank you &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;</description>
      <pubDate>Mon, 02 Oct 2023 06:20:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-numbers-of-days-between-tow-dates-by-name-and-get/m-p/3455485#M131711</guid>
      <dc:creator>FARIDMD</dc:creator>
      <dc:date>2023-10-02T06:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the numbers of days between tow dates by name and get the average too</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-numbers-of-days-between-tow-dates-by-name-and-get/m-p/3455623#M131718</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="601623" data-lia-user-login="FARIDMD" class="lia-mention lia-mention-user"&gt;FARIDMD&lt;/a&gt;&amp;nbsp;, could you share a sample file?&lt;BR /&gt;&lt;BR /&gt;Do you want to calculate in a measure or column in the table will work?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 07:44:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-numbers-of-days-between-tow-dates-by-name-and-get/m-p/3455623#M131718</guid>
      <dc:creator>gaurav-lakhotia</dc:creator>
      <dc:date>2023-10-02T07:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the numbers of days between tow dates by name and get the average too</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-numbers-of-days-between-tow-dates-by-name-and-get/m-p/3459059#M131897</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="601623" data-lia-user-login="FARIDMD" class="lia-mention lia-mention-user"&gt;FARIDMD&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest you to do some transformation on your table and then calculate the result you want.&lt;/P&gt;
&lt;P&gt;Old Table:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;New Table:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YlWMjIwMtI3sNQ3MgdznRCChob6hsZIXCMY1xlJ0ACoF8Y11jcAKUPimukbGSJxLfUNgCbEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}}),
    #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Custom", each if Text.Contains([Name], "/") then "" else [Name]),
    #"Filled Down" = Table.FillDown(#"Added Conditional Column",{"Custom"}),
    #"Replaced Value" = Table.ReplaceValue(#"Filled Down","",null,Replacer.ReplaceValue,{"Custom"}),
    #"Filled Down1" = Table.FillDown(#"Replaced Value",{"Custom"}),
    #"Added Conditional Column1" = Table.AddColumn(#"Filled Down1", "Date", each if [Name] = [Custom] then "" else [Name]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Conditional Column1",{{"Custom", type text}, {"Date", type date}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type1", each ([Date] &amp;lt;&amp;gt; null)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Name"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "Name"}}),
    #"Grouped Rows" = Table.Group(#"Renamed Columns", {"Name"}, {{"Rows", each _, type table [Name=nullable text, Date=nullable date]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Index", each Table.AddIndexColumn([Rows],"Index",1)),
    #"Expanded Index" = Table.ExpandTableColumn(#"Added Custom", "Index", {"Date", "Index"}, {"Index.Date", "Index.Index"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Expanded Index",{{"Index.Date", "Date"}, {"Index.Index", "Index"}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Renamed Columns1",{"Rows"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Removed Columns1",{{"Date", type date}, {"Index", Int64.Type}})
in
    #"Changed Type2"&lt;/LI-CODE&gt;
&lt;P&gt;Add a calculated column in your new table by dax.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DateDiff =
DATEDIFF (
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Name] ),
            'Table'[Index] &amp;lt; EARLIER ( 'Table'[Index] )
        )
    ),
    'Table'[Date],
    DAY
)&lt;/LI-CODE&gt;
&lt;P&gt;Result is as below.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&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;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 08:29:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Getting-the-numbers-of-days-between-tow-dates-by-name-and-get/m-p/3459059#M131897</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-04T08:29:55Z</dc:date>
    </item>
  </channel>
</rss>

