How to Combine Multiple Trading Rows into One Row Using Power Query
Question details
The user needs to consolidate cryptocurrency trading data by combining multiple rows that share the exact same timestamp into a single row, keeping fiat currency and cryptocurrency totals in separate columns.

- Product
- Power Query / Microsoft Excel
- Device & OS
- not provided
- Scenario
- Consolidating and flattening financial trading records where fiat and cryptocurrency transactions are split across multiple rows for the same transaction time.
- Observed behavior
- Trading data is scattered across multiple rows per timestamp, making it difficult to analyze a complete transaction in a single glance without proper grouping and merging.
Ensure your raw trading data is formatted as an Excel Table and verify that your timestamp column has a uniform 'DateTime' format without hidden millisecond variations that could prevent accurate grouping.
Combine Rows Using Group By and Merge in Power Query
This method groups data by timestamp, splits it into separate queries based on currency type, and merges them back together into a single, flat row.
Power Query can seamlessly perform this transformation using a combination of the 'Group By' feature and a 'Left Outer Join'. This approach is highly reliable for separating fiat currencies (like EUR or USD) and cryptocurrencies into dedicated columns per transaction timestamp.
Select your trading data range in Excel, navigate to the 'Data' tab, and click 'From Table/Range' to open the Power Query Editor.
Navigate to 'Transform' > 'Group By'. Select the timestamp column to group by, and create a new aggregated column to sum the trading amounts.
Right-click your newly grouped query in the left-hand Queries pane and select 'Duplicate'. You should now have two identical queries.
In the first query, filter the currency column to only show your fiat currency (e.g., EUR). In the second query, filter the column to only show your cryptocurrency.
Go to 'Home' > 'Merge Queries'. Select both queries from the dropdowns, click on the 'Timestamp' column in both preview windows to establish the join key, and select 'Left Outer' as the Join Kind. Click OK, then expand the required amount fields from the merged column.

Consolidate Trading Rows Using an Excel PivotTable
If Power Query feels too complex or rigid for your workflow, a standard PivotTable can quickly aggregate amounts by timestamp without permanently transforming the base data.
Analyze Financial Data Easily with WPS Office
Struggling with complex Power Query transformations in Microsoft Excel? WPS Spreadsheet provides powerful PivotTable and data consolidation tools that are fully compatible with your Excel files, offering a seamless, lightweight, and free alternative for advanced trading data analysis.
- 1. Download and Install WPS Office: Download the free WPS Office suite from the official website and install it on your device.
- 2. Open Your Excel File: Launch WPS Spreadsheet and open your existing .xlsx trading data file without losing any formatting.
- 3. Utilize PivotTables: Navigate to the Insert tab, select PivotTable, and effortlessly summarize your cryptocurrency rows into single timestamps.

Frequently Asked Questions
Why do my timestamps not group correctly in Power Query?
Timestamps might fail to group if they contain hidden millisecond values or distinct formatting. Use the 'Transform' tab to change the data type to strictly 'DateTime' or round the time to the nearest second before applying the 'Group By' function.
Can I combine rows without duplicating the query in Power Query?
Yes, advanced users can avoid duplicating the query by writing a custom 'M' code formula using Table.Group and conditional aggregation (e.g., grouping and creating custom columns that sum only if the currency matches). However, duplicating and merging is visually easier for beginners.
What happens to other text columns when I group rows by timestamp?
By default, any columns you do not specify in the 'Group By' menu are dropped. If you need to keep additional text columns (like transaction IDs), you must either add them as an aggregation using the 'All Rows' operation or merge them back in from the original dataset later.
Will a Left Outer Join duplicate my data?
A Left Outer Join only creates duplicate rows if there are multiple matching records in the secondary table for a single key. Because you grouped your data by timestamp and filtered by a specific currency type, each timestamp will uniquely match 1-to-1, preventing unwanted duplication.




