≡ ▼
Work in Progress :: Please contact us to report errors, typos, etc.
=L_FLIP(array, [dimension])
=L_FLIPUD(array)
=L_FLIPLR(array)
ArgumentDescriptionExample
arrayAn array consisting of numbers or text{1, 2, 3; "A", "B", "C"}
dimension1=Rows (default), 2=Columns1

Description

Reversing the order of the the rows or columns of an array can be done using CHOOSEROWS, CHOOSECOLS and the SEQUENCE functions. However, remembering how to do it may take time. FLIP is the more general function because it lets you choose either dimension=1 (same as FLIPUD) or dimension=2 (same as FLIPLR). FLIPLR means "flip left-right." FLIPUD means "flip up-down."

L_FLIPLR(array) = CHOOSECOLS(array,SEQUENCE(1,COLUMNS(array),COLUMNS(array),-1))
L_FLIPUD(array) = CHOOSEROWS(array,SEQUENCE(ROWS(array),1,ROWS(array),-1))

If your data is already sorted, then changing the sort direction may be the same thing as FLIP. However, if you specifically do NOT want to sort your data and ONLY want to reverse the order, that is where FLIP is handy.

Lambda Formula

This code for using L_FLIP, L_FLIPUD, L_FLIPLR in Excel is provided under the License as part of the LAMBDA Library, but to use just this function, you may copy the following code directly into your spreadsheet.

Code to Create Function via the Name Manager

Name: L_FLIP
Comment: Reverses the order of the rows, unless it is a single row or dimension=2, then reverses the columns
Refers To:
=LAMBDA(array,[dimension],
LET(doc,"https://www.vertex42.com/lambda/flip.html",
    dimension,IF(ISOMITTED(dimension),1,dimension),
    rows,ROWS(array),
    cols,COLUMNS(array),
    IF(OR(dimension=2,rows=1),
        CHOOSECOLS(array,SEQUENCE(1,cols,cols,-1)),
        CHOOSEROWS(array,SEQUENCE(rows,1,rows,-1))
    )
)

Name: L_FLIPUD
Comment: Reverses the order of the rows of an array
Refers To:
=LAMBDA(array,
LET(doc,"https://www.vertex42.com/lambda/flip.html",
    rows,ROWS(array),
    CHOOSEROWS(array,SEQUENCE(rows,1,rows,-1))
))

Name: L_FLIPLR
Comment: Reverses the order of the columns of an array
Refers To:
=LAMBDA(array,
LET(doc,"https://www.vertex42.com/lambda/flip.html",
    cols,COLUMNS(array),
    CHOOSECOLS(array,SEQUENCE(1,cols,cols,-1))
))

Code for AFE Workbook Module (Excel Labs Add-in)

/**
* Reverses the order of the rows, unless it is a single row or 
* dimension=2, then reverses the columns
*/
L_FLIP = LAMBDA(array,[dimension],
LET(doc,"https://www.vertex42.com/lambda/flip.html",
    dimension,IF(ISOMITTED(dimension),1,dimension),
    rows,ROWS(array),
    cols,COLUMNS(array),
    IF(OR(dimension=2,rows=1),
        CHOOSECOLS(array,SEQUENCE(1,cols,cols,-1)),
        CHOOSEROWS(array,SEQUENCE(rows,1,rows,-1))
    )
));

/**
* Reverses the order of the rows of an array
*/
L_FLIPUD = LAMBDA(array,
LET(doc,"https://www.vertex42.com/lambda/flip.html",
    rows,ROWS(array),
    CHOOSEROWS(array,SEQUENCE(rows,1,rows,-1))
));

/**
* Reverses the order of the columns of an array
*/
L_FLIPLR = LAMBDA(array,
LET(doc,"https://www.vertex42.com/lambda/flip.html",
    cols,COLUMNS(array),
    CHOOSECOLS(array,SEQUENCE(1,cols,cols,-1))
));

Named Function for Google Sheets

Name: L_FLIP
Description: Reverses the order of the rows, unless it is a single row or dimension=2, then reverses the columns
Arguments: array, dimension
Function:

LET(doc,"https://www.vertex42.com/lambda/flip.html",
    dimension,IF(ISBLANK(dimension),1,dimension),
    rows,ROWS(array),
    cols,COLUMNS(array),
    IF(OR(dimension=2,rows=1),
        CHOOSECOLS(array,SEQUENCE(1,cols,cols,-1)),
        CHOOSEROWS(array,SEQUENCE(rows,1,rows,-1))
    )
)
Warning
These functions are not compatible between Excel and Google Sheets. When using these functions, you will not be able to convert the Excel file to Google Sheets or vice versa without problems.

FLIP Examples

Example
Use FLIP, FLIPLR or FLIPUD to reverse the order of rows and columns of the array shown in the image. FLIP, FLIPLR and FLIPUD Example
Test: Copy and Paste the LET function into a cell
=LET(
    array, {"A1","B1","C1"; "A2","B2","C2"; "A3","B3","C3"},
    L_FLIP(array,1)
)

=LET(
    array, {"A1","B1","C1"; "A2","B2","C2"; "A3","B3","C3"},
    L_FLIPLR(array)
)

=LET(
    array, {"A1","B1","C1"; "A2","B2","C2"; "A3","B3","C3"},
    L_FLIPUD(array)
)
Disclaimer: This article is meant for educational purposes only. See the License regarding the LAMBDA code, and the site Terms of Use for the documentation.