Imagine I have the following dataset.
Product / IsOpen / Date 1 / 0 / 21 / 05 / 2009 1 / 1 / 22 / 05 / 2009
How can I filter/delete data previously to the first IsOpen = 1 ?? By creating a new table or even in Powerquery. I just want data starting from its first IsOpen = 1.
Thanks!
Starting with this table in Power Query:
Sort by the "Date" column. (Click the down arrow button at the top right of the "Date" column and then select "Sort Ascending".) The table will basically look the same, except the dates will be in order and the down arrow button will change to this:
Add an index. (Click the "Add Column" tab and then "Index Column".)
Group by "IsOpen" and determine the minimum index value for each "IsOpen" value. (Click the "Transform" tab and then "Group By". Then fill in the pop-up window like this:
...and click "OK".) You'll see this:
Filter out the 0's in "IsOpen". (Click on the down arrow button at the top right of the "IsOpen" column and then deselect "0" in the list.)
You'll see this:
Remove the rows with 0's in "IsOpen" that occur before the first 1. (Here is the "trick" that does what you want. I found it on Ken Puls's blog, "The Ken Puls (Excelguru) Blog":
Click the "Fx" to the left of the formula bar and overwrite what appears with this:
= Table.Skip(#"Added Index",#"Filtered Rows"[MinIndex]{0})
Then press enter and you'll see this:
Notice the 0 "IsOpen" that occurred before the first 1 "IsOpen", which was at "Index" 0, is now gone.)