HOW TO REVERSE ROWS IN POWER QUERY

INTRODUCTION

If you have been using the MICROSOFT EXCEL software for some time, you must have heard or read about the word POWER QUERY.

POWER QUERY IS A DATA SHAPING TOOL WHERE WE CAN BRING THE DATA THROUGH A CONNECTION FROM VARIOUS SOURCES, DO SOME SHAPING SUCH AS REMOVING ROWS, COLUMNS, CHANGING DATA TYPES, TRIMMING THE DATA ETC. AND GET IT FINALLY FOR THE ANALYSIS IN OUR MAIN SOFTWARE SUCH AS MICROSOFT EXCEL OR MICROSOFT POWER BI .

FOR THE INTRODUCTION OF POWER QUERY, CLICK HERE.

Power Query tool, in fact, has immense powers to shape up the data in the way we want.

We’ll cover a lot of practical problems to sort them out with the help of the POWER QUERY.

In this article, we would learn how to REVERSE THE ROWS using POWER QUERY in Excel or POWER BI.

With the reversal of rows we mean to reverse the sequence of the rows.

E.g.

If we have any data in a pattern like

ROW 1

ROW 2

ROW 3

We want to reverse it and create the table in the sequence as

ROW 3

ROW 2

ROW 1

Let us understand how we can do that in POWER QUERY.


GETTING THE EXAMPLE READY

For the example, we are going to take an Excel Sheet containing fictitious table just to understand how we can reverse the rows.

We have already performed a few steps which can be learnt here. [ www.gyankosh.net//powerbi ]
FOLLOW THE STEPS TO CLEAN AND SHAPE THE DATA:IMPORT THE DATA INTO POWER QUERY.

  • Launch the POWER QUERY EDITOR.
  • Choose , import from EXCEL.
  • Select the EXCEL file.
  • Choose the table from the navigator and click TRANSFORM DATA.

The following picture shows the data as it enters the POWER QUERY EDITOR

EXAMPLE DATA


REVERSING THE ROWS OF THE DATA IN POWER QUERY

STEPS TO REVERSE A TABLE IN POWER QUERY EDITOR:

  • After the table is cleaned and shaped up, go to TRANSFORM TAB.
  • Choose REVERSE ROWS under the section TABLE .
  • The rows will be reversed. The last row will become the first and first row will become the last.
STEPS TO REVERSE THE ROWS IN EXCEL USING POWER QUERY

So, we have successfully reversed the rows of a data table in power query which can be further used in Excel or power bi.

In the animated picture above, we show the use of REVERSE ROWS function and then clicking it again the rows are again brought to the previous original sequence.