I have been playing around quite a bit with powerquery to import all kinds of files and transform them in usable tables in excel. But recently I stumbled upon a problem I don't seem to find a solution for.
After some steps in my query I finally have the following result :
<table border="1">
<tr><th>Column 1</th><th>Column 2</th></tr>
<tr><td>Country</td><td>France</td></tr>
<tr><td>Number of hits</td><td>10</td></tr>
<tr><td>Number of misses</td><td>5</td></tr>
<tr><td>Country</td><td>UK</td></tr>
<tr><td>Number of hits</td><td>150</td></tr>
<tr><td>Number of misses</td><td>35</td></tr>
<tr><td>Country</td><td>Japan</td></tr>
<tr><td>Number of hits</td><td>5</td></tr>
<tr><td>Country</td><td>China</td></tr>
<tr><td>Number of hits</td><td>50</td></tr>
<tr><td>Number of misses</td><td>3</td></tr>
</table>
So, normally I always expected each time a line with "Country", followed by a line with "hits" followed by a line with "misses" (and lots of other lines in between that i don't need and filtered out in previous steps).
But it now turns out that for countries where the number of misses = 0 there is not even a row available in the input file. In my example this is the line for "Japan"
My idea was to find some kind of function that does this :
IF < Column1 of current line > ='Number of hits' AND < Column1 of next line > ='Country' THEN
insert ['Number of misses','0'] after the current line.
The end result should then look like this :
<table border="1">
<tr><th>Column 1</th><th>Column 2</th></tr>
<tr><td>Country</td><td>France</td></tr>
<tr><td>Number of hits</td><td>10</td></tr>
<tr><td>Number of misses</td><td>5</td></tr>
<tr><td>Country</td><td>UK</td></tr>
<tr><td>Number of hits</td><td>150</td></tr>
<tr><td>Number of misses</td><td>35</td></tr>
<tr><td>Country</td><td>Japan</td></tr>
<tr><td>Number of hits</td><td>5</td></tr>
<tr><td><b>Number of misses</b></td><td><b>0</b></td></tr>
<tr><td>Country</td><td>China</td></tr>
<tr><td>Number of hits</td><td>50</td></tr>
<tr><td>Number of misses</td><td>3</td></tr>
</table>
All of this should happen in the (advanced) query part and not once the data is imported in a table in excel.