Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
wooand
Helper II
Helper II

Aggregate alternate rows

OK, so this one has me totally stumped.

 

I have a list of swap transactions, where financial instruments are exchanged on day one, and are swapped back on day x at the end of the term. 

 

For each transaction I have a reference, a trade date, a buy or sell and a rate.  For each transaction I then have the opposite data on the next line.  This means I have a table with all the correct data.

 

Now I need to put the data in line 2 alongside the data in line 1 so that I have a single line per transaction.  I can then add the details I need to add into a new column and off we go.  Except I have no clue how to place the details in line 2 into columns next to the original line 1 trade.

 

Any clues???  

 

1 ACCEPTED SOLUTION
MarkS
Resolver IV
Resolver IV

Hi @wooand,

 

To get the second line of data you could try this pattern.

1. Add a new index column starting at 1

2. Add another new index column starting at 0

3. Merge Query -  using the same table (left outer join)  merge on the index columns (first index column from the table shown on the top with the second index column from the table on the bottom.

4. Transform one of the index columns with modulo 2 (from the standard math transformations)

5. Filter out that column on 1

6. Expand the table

 

MarkS

 

View solution in original post

6 REPLIES 6
MarkS
Resolver IV
Resolver IV

Hi @wooand,

 

To get the second line of data you could try this pattern.

1. Add a new index column starting at 1

2. Add another new index column starting at 0

3. Merge Query -  using the same table (left outer join)  merge on the index columns (first index column from the table shown on the top with the second index column from the table on the bottom.

4. Transform one of the index columns with modulo 2 (from the standard math transformations)

5. Filter out that column on 1

6. Expand the table

 

MarkS

 

Mark,

 

I have a question.  I have been using your answer to this question for some time with great success, but I am struggling when I have two rows the same.  See below - lines 5 and 6 are the same amount - but when I use this process to bring the lines alongside one another the duiplicated information seems to create a problem in that it only mirrors the row once, thereby making every line one line out.  I've tried using 'Full Outer' but that didn't work.  

 

Any ideas?

 

A.

 

 

Capture.PNG

Hi @wooand,

I cannot re-create what you are experiencing.  When I try it this is what I am getting:

 Community 09-18-2018.PNG

Well done Mark, that's nailed it.

 

Many thanks.

 

 

Zubair_Muhammad
Community Champion
Community Champion

Hi @wooand

 

If each transaction has a unique reference and 2 rows only, I believe it should be doable

 

Could you paste some sample data and expected reults?

 

May be 10-15 rows of sample data and your desired RESULT


Regards
Zubair

Please try my custom visuals

Thanks Zubair.  I've taken the amounts out, but I'm sure you get the gist:

 

PairTrade DateValue DateTrade TypeCUST Side AllocationAmountBUY CCYSELL CCYUSD CostUSD Amount
EURCHF03/01/201706/01/2017SWAPSELL10.00CHFEUR1.0010.00
EURCHF03/01/201711/01/2017SWAPBUY10.00EURCHF1.0010.00
EURCHF03/01/201706/01/2017SWAPBUY10.00EURCHF1.0010.00
EURCHF03/01/201711/01/2017SWAPSELL10.00CHFEUR1.0010.00
EURGBP03/01/201701/02/2017SWAPBUY10.00EURGBP1.0010.00
EURGBP03/01/201704/01/2017SWAPSELL10.00GBPEUR1.0010.00
EURGBP03/01/201704/01/2017SWAPSELL10.00GBPEUR1.0010.00
EURGBP03/01/201701/02/2017SWAPBUY10.00EURGBP1.0010.00
EURGBP03/01/201731/01/2017SWAPSELL10.00GBPEUR1.0010.00
EURGBP03/01/201705/01/2017SWAPBUY10.00EURGBP1.0010.00
EURGBP03/01/201731/01/2017SWAPBUY10.00EURGBP1.0010.00
EURGBP03/01/201705/01/2017SWAPSELL10.00GBPEUR1.0010.00
EURGBP03/01/201711/01/2017SWAPBUY10.00EURGBP1.0010.00
EURGBP03/01/201706/01/2017SWAPSELL10.00GBPEUR1.0010.00

 

And the target is to have the far legs currently on the second row captured alongside their near legs:

 

PairTrade DateValue DateTrade TypeCUST Side AllocationAmountBUY CCYSELL CCYUSD CostUSD AmountValue DateTrade TypeCUST Side AllocationAmountBUY CCYSELL CCYUSD CostUSD Amount
EURCHF03/01/201706/01/2017SWAPSELL10.00CHFEUR1.0010.0011/01/2017SWAPBUY10.00EURCHF1.0010.00
EURCHF03/01/201706/01/2017SWAPBUY10.00EURCHF1.0010.0011/01/2017SWAPSELL10.00CHFEUR1.0010.00
EURGBP03/01/201701/02/2017SWAPBUY10.00EURGBP1.0010.0004/01/2017SWAPSELL10.00GBPEUR1.0010.00
EURGBP03/01/201704/01/2017SWAPSELL10.00GBPEUR1.0010.0001/02/2017SWAPBUY10.00EURGBP1.0010.00
EURGBP03/01/201731/01/2017SWAPSELL10.00GBPEUR1.0010.0005/01/2017SWAPBUY10.00EURGBP1.0010.00
EURGBP03/01/201731/01/2017SWAPBUY10.00EURGBP1.0010.0005/01/2017SWAPSELL10.00GBPEUR1.0010.00
EURGBP03/01/201711/01/2017SWAPBUY10.00EURGBP1.0010.0006/01/2017SWAPSELL10.00GBPEUR1.0010.00

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.