<?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: HTML into Two Meausures in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/HTML-into-Two-Meausures/m-p/2390770#M34934</link>
    <description>&lt;P&gt;You can't really do that in DAX unless you want to do some serious string gymnastics. However this is rather easy to achieve in Power Query as it has an XML parser.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that your HTML is suspicious.&amp;nbsp; instead of &amp;lt;th&amp;gt;&amp;nbsp; it uses &amp;lt;td&amp;gt;&amp;lt;strong&amp;gt; .&amp;nbsp; Not cool.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = "&amp;lt;table border=""1"" cellpadding=""1"" cellspacing=""1"" style=""width:500px""&amp;gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;CODE&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;DC&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;TDM&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;QTY&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;TYPE&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;118EM1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1234&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;AAAA&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;5000&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;CCCC&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;114EM1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1432&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;BBBB&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;8000&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;DDDD&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;",
    #"Parsed XML" = Xml.Tables(Source),
    #"Changed Type" = Table.TransformColumnTypes(#"Parsed XML",{{"Attribute:border", Int64.Type}, {"Attribute:cellpadding", Int64.Type}, {"Attribute:cellspacing", Int64.Type}, {"Attribute:style", type text}}),
    tbody = #"Changed Type"{0}[tbody],
    tr = tbody{0}[tr],
    #"Expanded td" = Table.ExpandTableColumn(tr, "td", {"strong", "Element:Text"}, {"strong", "Element:Text"}),
    #"Added Index" = Table.AddIndexColumn(#"Expanded td", "Index", 0, 1, Int64.Type),
    #"Replaced Value" = Table.ReplaceValue(#"Added Index",null,each #"Added Index"[strong]{Number.Mod([Index],5)},Replacer.ReplaceValue,{"strong"}),
    #"Filtered Rows" = Table.SelectRows(#"Replaced Value", each ([#"Element:Text"] &amp;lt;&amp;gt; null)),
    #"Replaced Value1" = Table.ReplaceValue(#"Filtered Rows",each [Index],each Number.RoundDown([Index]/5),Replacer.ReplaceValue,{"Index"}),
    #"Pivoted Column" = Table.Pivot(#"Replaced Value1", List.Distinct(#"Replaced Value1"[strong]), "strong", "Element:Text"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Pivoted Column",{{"QTY", Int64.Type}})
in
    #"Changed Type1"&lt;/LI-CODE&gt;
&lt;H5&gt;How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".&lt;/H5&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Mar 2022 00:10:53 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2022-03-14T00:10:53Z</dc:date>
    <item>
      <title>HTML into Two Meausures</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/HTML-into-Two-Meausures/m-p/2389719#M34908</link>
      <description>&lt;P&gt;Dear Friends!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your assistance will much appreaciated,&lt;/P&gt;&lt;P&gt;I have a column where each cell is a table with different number of rows and quantities. The cell is presented in HTML format.&lt;/P&gt;&lt;P&gt;I wish to extract two measurements:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;table border=""1"" cellpadding=""1"" cellspacing=""1"" style=""width:500px""&amp;gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;CODE&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;DC&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;TDM&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;QTY&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;TYPE&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;118EM1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1234&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;AAAA&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;5000&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;CCCC&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;114EM1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1432&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;BBBB&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;8000&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;DDDD&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Number of Rows (w/o header) ==&amp;gt; in this case 2&lt;/LI&gt;&lt;LI&gt;Total QTY ==&amp;gt; in this case 13000&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Can you please help with a visual of function?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 07:41:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/HTML-into-Two-Meausures/m-p/2389719#M34908</guid>
      <dc:creator>joe100</dc:creator>
      <dc:date>2022-03-12T07:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: HTML into Two Meausures</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/HTML-into-Two-Meausures/m-p/2390770#M34934</link>
      <description>&lt;P&gt;You can't really do that in DAX unless you want to do some serious string gymnastics. However this is rather easy to achieve in Power Query as it has an XML parser.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that your HTML is suspicious.&amp;nbsp; instead of &amp;lt;th&amp;gt;&amp;nbsp; it uses &amp;lt;td&amp;gt;&amp;lt;strong&amp;gt; .&amp;nbsp; Not cool.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = "&amp;lt;table border=""1"" cellpadding=""1"" cellspacing=""1"" style=""width:500px""&amp;gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;CODE&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;DC&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;TDM&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;QTY&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;TYPE&amp;lt;/strong&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;118EM1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1234&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;AAAA&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;5000&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;CCCC&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;114EM1&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;1432&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;BBBB&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;8000&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;DDDD&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;",
    #"Parsed XML" = Xml.Tables(Source),
    #"Changed Type" = Table.TransformColumnTypes(#"Parsed XML",{{"Attribute:border", Int64.Type}, {"Attribute:cellpadding", Int64.Type}, {"Attribute:cellspacing", Int64.Type}, {"Attribute:style", type text}}),
    tbody = #"Changed Type"{0}[tbody],
    tr = tbody{0}[tr],
    #"Expanded td" = Table.ExpandTableColumn(tr, "td", {"strong", "Element:Text"}, {"strong", "Element:Text"}),
    #"Added Index" = Table.AddIndexColumn(#"Expanded td", "Index", 0, 1, Int64.Type),
    #"Replaced Value" = Table.ReplaceValue(#"Added Index",null,each #"Added Index"[strong]{Number.Mod([Index],5)},Replacer.ReplaceValue,{"strong"}),
    #"Filtered Rows" = Table.SelectRows(#"Replaced Value", each ([#"Element:Text"] &amp;lt;&amp;gt; null)),
    #"Replaced Value1" = Table.ReplaceValue(#"Filtered Rows",each [Index],each Number.RoundDown([Index]/5),Replacer.ReplaceValue,{"Index"}),
    #"Pivoted Column" = Table.Pivot(#"Replaced Value1", List.Distinct(#"Replaced Value1"[strong]), "strong", "Element:Text"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Pivoted Column",{{"QTY", Int64.Type}})
in
    #"Changed Type1"&lt;/LI-CODE&gt;
&lt;H5&gt;How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".&lt;/H5&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 00:10:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/HTML-into-Two-Meausures/m-p/2390770#M34934</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2022-03-14T00:10:53Z</dc:date>
    </item>
  </channel>
</rss>

