Skip to main content

Turn Data Sideways



Someone built this lookup table sideways, stretching across C1:N2. I realize that I could use HLOOKUP instead of VLOOKUP, but I prefer to turn the data back to a vertical orientation.

Copy C1:N2. Right-click in A4 and choose the Transpose option under the Paste Options. Transpose is the fancy Excel word for “turn the data sideways.”

Copy the horizontal lookup table in C1:N2. Right-click in a blank cell. The fourth icon under Paste Options is called Transpose. Choose that and you will paste a sideways copy of the original table.

I transpose a lot. But I use Alt+ESEEnter to transpose instead of the right-click.

There is a problem, though. Transpose is a one-time snapshot of the data. What if you have formulas in the horizontal data? Is there a way to transpose with a formula?

The first way is a bit bizarre. If you are trying to transpose 12 horizontal cells, you need to select 12 vertical cells in a single selection. Start typing a formula such as =TRANSPOSE(C2:N2) in the active cell but do not press Enter. Instead, hold down Ctrl+Shift and then press Enter. This puts a single array formula in the selected cells. This TRANSPOSE formula is going to return 12 answers, and they will appear in the 12 selected cells, as shown below.

Select the 12 cells B4:B15. Type a formula =TRANSPOSE(C2:N2) but do not press Enter. Instead, hold while holding down Ctrl and Shift, press Enter. This enters a single formula in 12 cells at one time.

As the data in the horizontal table changes, the same values appear in your vertical table, as shown below.

The results: as the original formulas in C2:N2 recalculate, the results in the vertical range are updated.

But array formulas are not well known. Some spreadsheet rookie might try to edit your formula and forget to press Ctrl+Shift+Enter.

To avoid using the array formula, use a combination of INDEX and ROW, as shown in the figure below. =ROW(1:1) is a clever way of writing the number 1. As you copy this formula down, the row reference changes to 2:2 and returns a 2.

The INDEX function says you are getting the answers from C2:N2, and you want the nth item from the range.

A different solution that does not require Ctrl+Shift+Enter. The formula for January in B4 is =INDEX($C$2:$N$2,ROW(1:1)). The ROW(1:1) is a complicated way to write the number 1.

In the figure below, =FORMULATEXT in column C shows how the formula changes when you copy down.

As you copy that formula down, the reference to ROW(1:1) automatically changes to ROW(2:2) and so on.

Comments

Popular posts from this blog

20 Time Intelligence Dax Measures

20 Time Intelligence DAX measures in Power BI with examples: Year-to-Date Sales: css Copy code YTD Sales = TOTALYTD( [Total Sales] , Calendar [Date] ) Month-to-Date Sales: css Copy code MTD Sales = TOTALMTD( [Total Sales] , Calendar [Date] ) Quarter-to-Date Sales: css Copy code QTD Sales = TOTALQTD( [Total Sales] , Calendar [Date] ) Previous Year Sales: mathematica Copy code Previous Year Sales = CALCULATE ( [ Total Sales ] , SAMEPERIODLASTYEAR ( Calendar [ Date ] ) ) Year-over-Year Growth: css Copy code YoY Growth = DIVIDE( [Total Sales] - [Previous Year Sales] , [Previous Year Sales] ) Rolling 3-Month Average Sales: sql Copy code 3 M Rolling Avg Sales = AVERAGEX(DATESINPERIOD(Calendar[ Date ], MAX (Calendar[ Date ]), -3 , MONTH ), [Total Sales]) Cumulative Sales: scss Copy code Cumulative Sales = SUMX (FILTER(ALL(Calendar), Calendar [Date] <= MAX (Calendar[Date])), [Total Sales] ) Running Total Sales: scss Copy code Running Total Sales = SUMX (FILTER(ALL(Calendar), Calen...

40 Power Query Editor features in Power BI

40 Power Query Editor features in Power BI along with examples: 1. Filter Rows: Remove rows based on conditions. Example: Remove rows with a null value in the "CustomerName" column. 2. Remove Duplicates: Eliminate duplicate rows. Example: Remove duplicate entries based on the "OrderID" column. 3. Sort Rows: Arrange rows in ascending or descending order. Example: Sort data by "Date" column in descending order. 4. Replace Values: Substitute one value with another. Example: Replace "N/A" with "Unknown" in the "Status" column. 5. Split Columns: Divide a column into multiple columns. Example: Split "FullName" into "FirstName" and "LastName." 6. Merge Queries: Combine data from multiple sources. Example: Merge customer and order data based on the "CustomerID." 7. Group By: Aggregate data based on a specific column. Example: Group sales data by "ProductCategory" and calculate the sum ...