<?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: Text Duration Conversion in Quick Measures Gallery</title>
    <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Text-Duration-Conversion/m-p/2046355#M746</link>
    <description>&lt;P&gt;I revisited this solution after I remembered my Mythical DAX Index. A perhaps more elegant approach to Text to Table if you don't have | characters in your text is this:&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-markup"&gt;&lt;CODE&gt;    VAR __Text = SUBSTITUTE(__SearchText,__Separator,"|")
    VAR __Table = 
        ADDCOLUMNS(
            GENERATESERIES(1,__Count,1),
            "__Word",PATHITEM(__Text,[Value],TEXT)
        )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you did have | characters in your text, you would have to SUBSTITUTE them out and then SUBSTITUTE them back in for each word which could get a little messy.&lt;/P&gt;</description>
    <pubDate>Mon, 30 Aug 2021 13:52:53 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2021-08-30T13:52:53Z</dc:date>
    <item>
      <title>Text Duration Conversion</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Text-Duration-Conversion/m-p/2036198#M740</link>
      <description>&lt;P&gt;I keep finding uses for this crazy &lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Text-to-Table/m-p/1312929#M594" target="_self"&gt;Text to Table&lt;/A&gt; pattern. This one converts text durations to numeric values. Didn't know this was a thing but has come up a couple times in a matter of days. I created a hacky version of this but this one is much, much better. Handles single and plural words, capitalization or not, any order, etc.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Duration = 
    VAR __Separator = " "
    VAR __SearchText = MAX('Table'[Text Duration])
    VAR __Len = LEN(__SearchText)
    VAR __Count = __Len - LEN(SUBSTITUTE(__SearchText,__Separator,"")) + 1
    VAR __Table = 
        ADDCOLUMNS(
            ADDCOLUMNS(
                GENERATESERIES(1,__Count,1),
                "__Word",
                    VAR __Text = SUBSTITUTE(__SearchText,__Separator,"|",IF([Value]=1,1,[Value]-1))
                    VAR __Start =
                        SWITCH(TRUE(),
                            __Count = 1,1,
                            [Value] = 1,1,
                            FIND("|",__Text)+1
                        )
                    VAR __End = 
                        SWITCH(TRUE(),
                            __Count = 1,__Len,
                            [Value] = 1,FIND("|",__Text) - 1,
                            [Value] = __Count,__Len,
                            FIND(__Separator,__Text,__Start)-1
                        )
                    VAR __Word = MID(__Text,__Start,__End - __Start + 1)
                RETURN __Word
            ),
            "__Key",
                SWITCH(TRUE(),
                    SEARCH("day",[__Word],,0)&amp;gt;0,"day",
                    SEARCH("hour",[__Word],,0)&amp;gt;0,"hour",
                    SEARCH("minute",[__Word],,0)&amp;gt;0,"minute",
                    SEARCH("second",[__Word],,0)&amp;gt;0,"second",
                    BLANK()
                )
        )
    VAR __Days = MAXX(FILTER(__Table,[Value] = MAXX(FILTER(__Table,[__Key]="day"),[Value]) - 1),[__Word])+0
    VAR __Hours = MAXX(FILTER(__Table,[Value] = MAXX(FILTER(__Table,[__Key]="hour"),[Value]) - 1),[__Word])+0
    VAR __Minutes = MAXX(FILTER(__Table,[Value] = MAXX(FILTER(__Table,[__Key]="minute"),[Value]) - 1),[__Word])+0
    VAR __Seconds = MAXX(FILTER(__Table,[Value] = MAXX(FILTER(__Table,[__Key]="second"),[Value]) - 1),[__Word])+0
RETURN
    __Days * 1000000 + __Hours * 10000 + __Minutes * 100 + __Seconds&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="reportid hidden"&gt;eyJrIjoiZTk1MWVkZGItN2Y0Yy00ZmM4LTliMDYtYmM4MTFkMzc0NjhkIiwidCI6IjRhMDQyNzQzLTM3M2EtNDNkMi04MjdiLTAwM2Y0YzdiYTFlNSIsImMiOjN9&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 23:52:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Text-Duration-Conversion/m-p/2036198#M740</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-24T23:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Text Duration Conversion</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Text-Duration-Conversion/m-p/2046355#M746</link>
      <description>&lt;P&gt;I revisited this solution after I remembered my Mythical DAX Index. A perhaps more elegant approach to Text to Table if you don't have | characters in your text is this:&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-markup"&gt;&lt;CODE&gt;    VAR __Text = SUBSTITUTE(__SearchText,__Separator,"|")
    VAR __Table = 
        ADDCOLUMNS(
            GENERATESERIES(1,__Count,1),
            "__Word",PATHITEM(__Text,[Value],TEXT)
        )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you did have | characters in your text, you would have to SUBSTITUTE them out and then SUBSTITUTE them back in for each word which could get a little messy.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 13:52:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Text-Duration-Conversion/m-p/2046355#M746</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-08-30T13:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: Text Duration Conversion</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Text-Duration-Conversion/m-p/2064259#M763</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With having the same text duration format, what would the formula look like if the conversion needed for the duration would be in decimals (hhhh.mm) instead of your example above thats in dd:hh:mm:ss? Appreciate your updates.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 12:39:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Text-Duration-Conversion/m-p/2064259#M763</guid>
      <dc:creator>Nelvbautista</dc:creator>
      <dc:date>2021-09-08T12:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Text Duration Conversion</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Text-Duration-Conversion/m-p/2064332#M764</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="321556" data-lia-user-login="Nelvbautista" class="lia-mention lia-mention-user"&gt;Nelvbautista&lt;/a&gt;&amp;nbsp;So if you have 300 hours and 52 minutes do you want that as 300.52 or 300 + 52/60? The first one is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;RETURN
    __Hours + __Minutes / 100



or

RETURN
    __Days * 24 + __Hours + __Minutes / 100&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;RETURN
    __Hours + __Minutes / 60


or

RETURN
    __Days * 24 + __Hours + __Minutes / 60&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 13:05:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Text-Duration-Conversion/m-p/2064332#M764</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2021-09-08T13:05:14Z</dc:date>
    </item>
  </channel>
</rss>

