<?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: Split Text into multiple columns in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Split-Text-into-multiple-columns/m-p/1330409#M23565</link>
    <description>&lt;P&gt;Hi Pat,&lt;/P&gt;&lt;P&gt;Wonderful. Thanks for the solution. This works for me. Can you guide me how to replace the example text with actual column from my table ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Aug 2020 00:33:17 GMT</pubDate>
    <dc:creator>senthil_venkat</dc:creator>
    <dc:date>2020-08-28T00:33:17Z</dc:date>
    <item>
      <title>Split Text into multiple columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Split-Text-into-multiple-columns/m-p/1330289#M23560</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;I have an data where one specific column "Total Duration" which has the data combined with days, hours and minutes in one field, as shown below.&amp;nbsp; &amp;nbsp; Is there any way to convert this data to use for calculating actual durations ? or Averages, Total Days, TOtal Hours etc..&amp;nbsp; or any calculation ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Say for ex.. If need to get average of 10 rows, currently with this "Text" type it is not possible for me. I looking for some help to convert this text to values which can used for calculations.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;6 Days 17 Hours 20 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6 Days 17 Hours 20 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2 Days 17 Hours 18 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2 Days 17 Hours 18 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8 Days 15 Hours 46 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8 Days 35 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6 Days 6 Hours 50 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6 Days 23 Hours 14 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15 Hours 19 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15 Hours 19 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15 Hours 15 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15 Hours 15 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2 Days 15 Hours 10 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2 Days 15 Hours 10 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1 Day 15 Hours 8 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1 Day 15 Hours 8 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15 Hours 8 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15 Hours 8 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1 Day 15 Hours 8 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1 Day 15 Hours 8 Minutes&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 27 Aug 2020 22:20:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Split-Text-into-multiple-columns/m-p/1330289#M23560</guid>
      <dc:creator>senthil_venkat</dc:creator>
      <dc:date>2020-08-27T22:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: Split Text into multiple columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Split-Text-into-multiple-columns/m-p/1330349#M23561</link>
      <description>&lt;P&gt;Please see the M code below for how to do this by extracting the numbers (from end of input since not all rows have Days value).&amp;nbsp;&amp;nbsp;To see how it works, just create a blank query, go to Advanced Editor, and replace the text there with the M code below.&amp;nbsp; It results in columns for Days, Hours, and Minutes, along with a Total Duration column, and a total minutes column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlNwSawsVjA0V/DILy0qVjAyUPDNzCstSS1WitUhKG2EJm1oQYq0BVTaFCptYoZN2tgUm4vMoHpMsbrXyBhmowmKNNwqQ0sSxU2JEjdC85Eh9uDCIW0IkkbIWpAgSZowefbEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Inserted Text Between Delimiters" = Table.AddColumn(#"Changed Type", "Minutes", each Text.BetweenDelimiters([Column1], " ", " ", {1, RelativePosition.FromEnd}, 0), type text),
    #"Inserted Text Between Delimiters1" = Table.AddColumn(#"Inserted Text Between Delimiters", "Hours", each Text.BetweenDelimiters([Column1], " ", " ", {3, RelativePosition.FromEnd}, 0), type text),
    #"Inserted Text Before Delimiter" = Table.AddColumn(#"Inserted Text Between Delimiters1", "Days", each Text.BeforeDelimiter([Column1], " ", {4, RelativePosition.FromEnd}), type text),
    #"Changed Type1" = Table.TransformColumnTypes(#"Inserted Text Before Delimiter",{{"Minutes", Int64.Type}, {"Hours", Int64.Type}, {"Days", Int64.Type}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type1",null,0,Replacer.ReplaceValue,{"Days"}),
    #"Added Custom" = Table.AddColumn(#"Replaced Value", "Duration", each #duration([Days]+0,[Hours],[Minutes],0)),
    #"Changed Type2" = Table.TransformColumnTypes(#"Added Custom",{{"Duration", type duration}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type2", "Total Minutes", each Duration.TotalMinutes([Duration])),
    #"Changed Type3" = Table.TransformColumnTypes(#"Added Custom1",{{"Total Minutes", Int64.Type}})
in
    #"Changed Type3"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this works for you, please mark it as the solution.&amp;nbsp; Kudos are appreciated too.&amp;nbsp; Please let me know if not.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Pat&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 23:13:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Split-Text-into-multiple-columns/m-p/1330349#M23561</guid>
      <dc:creator>mahoneypat</dc:creator>
      <dc:date>2020-08-27T23:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Split Text into multiple columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Split-Text-into-multiple-columns/m-p/1330385#M23564</link>
      <description>&lt;P&gt;My logic is intuitive, first substitute Days/Hours/Minutes with 1440/60/1 respectively; then sum it up.&lt;/P&gt;&lt;P&gt;Pls refer to the following M code,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Replaced Value" = Table.ReplaceValue(Source,"Days","1440",Replacer.ReplaceText,{"Text"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","Hours","60",Replacer.ReplaceText,{"Text"}),
    #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","Minutes","1",Replacer.ReplaceText,{"Text"}),
    Custom1 = Table.TransformColumns(#"Replaced Value2", {"Text", each List.Transform(Text.Split(_, " "), Number.From)}),
    Custom2 = Table.TransformColumns(Custom1, {"Text", each
        let
            D = _{0}*_{1},
            h = _{2}?*_{3}?,
            H = if h=null then 0 else h,
            m = _{4}?*_{5}?,
            M = if m=null then 0 else m,
            span = D+H+M
        in
            span
        })
in
    Custom2&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 28 Aug 2020 00:00:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Split-Text-into-multiple-columns/m-p/1330385#M23564</guid>
      <dc:creator>CNENFRNL</dc:creator>
      <dc:date>2020-08-28T00:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Split Text into multiple columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Split-Text-into-multiple-columns/m-p/1330409#M23565</link>
      <description>&lt;P&gt;Hi Pat,&lt;/P&gt;&lt;P&gt;Wonderful. Thanks for the solution. This works for me. Can you guide me how to replace the example text with actual column from my table ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 00:33:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Split-Text-into-multiple-columns/m-p/1330409#M23565</guid>
      <dc:creator>senthil_venkat</dc:creator>
      <dc:date>2020-08-28T00:33:17Z</dc:date>
    </item>
  </channel>
</rss>

