<?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: Grouping multiple rows in Desktop</title>
    <link>https://community.fabric.microsoft.com/t5/Desktop/Grouping-multiple-rows/m-p/967943#M463564</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1522" data-lia-user-login="ImkeF" class="lia-mention lia-mention-user"&gt;ImkeF&lt;/a&gt; , can you help&lt;/P&gt;
&lt;P class="ics-element-donot-delete 1001_CC@"&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Mar 2020 03:43:46 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2020-03-11T03:43:46Z</dc:date>
    <item>
      <title>Grouping multiple rows</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Grouping-multiple-rows/m-p/967734#M463485</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a device that will write data into a table whenever an event occurs. An event means either the device is turned on or turned off, or an abnormality happened or the abnormality disappeared. Here is a sample table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;For example, according to rows 5 to 9, the device was Off for 22 sec, then turned On for 155 sec, then encountered an abnormality for 78 sec while still being On, then the abnormality disappeared and the device went back to normal for 56 sec, and then it turned Off and waited for 220 sec before being turned On again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to group different rows together to be considered as a single "cycle". The device is having a single "cycle" when it turns On until it turns Off. I will then need to analyze the durations for these "cycle"s, not single events. If I can make a conditional column that increments a variable based on the status like the picture below, then I can separate these events based on that conditional column.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Utimately, I want to add up all the duration based on each "cycle" (most likely putting it in a new table or so).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know if the Power Query or DAX can do this conditional column, but if not, I am open to other suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P class="ics-element-donot-delete 1001_CC@"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 01:30:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Grouping-multiple-rows/m-p/967734#M463485</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-11T01:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping multiple rows</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Grouping-multiple-rows/m-p/967943#M463564</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1522" data-lia-user-login="ImkeF" class="lia-mention lia-mention-user"&gt;ImkeF&lt;/a&gt; , can you help&lt;/P&gt;
&lt;P class="ics-element-donot-delete 1001_CC@"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 03:43:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Grouping-multiple-rows/m-p/967943#M463564</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-03-11T03:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping multiple rows</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Grouping-multiple-rows/m-p/968181#M463653</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you add a column where you check if "status" = "Off". Then use a an index-column like "Event" with unique values otherwise (a real null. That allows you to fill down the values found for the Off-values.&lt;/P&gt;
&lt;P&gt;But as this will not return a continuous series, there is another version where you group on that new column and add an index on the grouped data instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Paste the following coded into the advanced editor and follow the steps:&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("i45WMlTSUcpPS1OK1YlWMgKx88BMYwTTBEmFKULYDEnYHCFsAWXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Event = _t, Status = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Cycle", each if [Status] = "off" then [Event] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Cycle"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Filled Down",{{"Event", Int64.Type}, {"Status", type text}})
in
    #"Changed Type"&lt;/LI-CODE&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("i45WMlTSUcpPS1OK1YlWMgKx88BMYwTTBEmFKULYDEnYHCFsAWXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Event = _t, Status = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Cycle", each if [Status] = "off" then [Event] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Cycle"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Filled Down",{{"Event", Int64.Type}, {"Status", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Cycle"}, {{"CyclePartition", each _, type table [Event=number, Status=text, Cycle=text]}}),
    #"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Index", 1, 1),
    #"Expanded CyclePartition" = Table.ExpandTableColumn(#"Added Index", "CyclePartition", {"Event", "Status"}, {"Event", "Status"})
in
    #"Expanded CyclePartition"&lt;/LI-CODE&gt;
&lt;P class="ics-element-donot-delete 1001_CC@"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 06:36:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Grouping-multiple-rows/m-p/968181#M463653</guid>
      <dc:creator>ImkeF</dc:creator>
      <dc:date>2020-03-11T06:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping multiple rows</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Grouping-multiple-rows/m-p/969739#M464286</link>
      <description>&lt;P&gt;Thank you. This solves my problem.&lt;/P&gt;&lt;P class="ics-element-donot-delete 1001_CC@"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 21:05:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Grouping-multiple-rows/m-p/969739#M464286</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-11T21:05:03Z</dc:date>
    </item>
  </channel>
</rss>

