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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
WLou
Helper I
Helper I

Data Transform question (Pivot?)

Hi all

For some reason the report i'm downling is constructing the lis in an odd way see below first section 

Usually is to unpivot but this seems to pivot it, I have tried but that only applies to column with value 

Annotation 2020-02-18 103033.jpg

If there is a similar post please feel free to link in 

Thanks

Regards,

Wendy

 

1 ACCEPTED SOLUTION
DataChant
Most Valuable Professional
Most Valuable Professional

Hi @WLou,

 

To confirm - Are you looking to transform the From table to the To table? Applying a Pivot will not work, because the Pivot step will treat the missing values under "AA Trx Dimension ID" column as a new blank column. To get to the desired format, you would need to follow these steps.

  1. Start with the source table.
  2. Create two reference queries from the source query by right-clicking on the source query and selecting Reference. Repeat it twice, and rename the new queries NoBlanks and Blanks.
  3. In the NoBlanks query, apply a filter on the AA Trx Dimension ID column and remove empty values.
  4. In the Blanks query, apply a filter on the AA Trx Dimension ID and keep only the empty values.
  5. Remove the last two (and empty) columns of the Blanks query.
  6. If you don't have a unique key in your data, you would need to add to the NoBlanks query an Index column and then apply Divide-Integer on it to create a unique index for the multi-line records (See attached solution file in my last response). I also cover this technique in detail in Chapter 7 of my book "Collect, Combine & Transfer Data using Power Query in Excel and Power BI".
  7. Apply Pivot Column on the AA Trx Dimension ID  column of the NoBlanks query. In the advanced options of the Pivot Column, select Don't aggregate.
  8. Apply Append Queries As New on the Blanks and NoBlanks.

If you are not sure how to follow these instructions, please send me a sample report and I will attach the solution. 

 

View solution in original post

4 REPLIES 4
DataChant
Most Valuable Professional
Most Valuable Professional

Hi @WLou,

 

To confirm - Are you looking to transform the From table to the To table? Applying a Pivot will not work, because the Pivot step will treat the missing values under "AA Trx Dimension ID" column as a new blank column. To get to the desired format, you would need to follow these steps.

  1. Start with the source table.
  2. Create two reference queries from the source query by right-clicking on the source query and selecting Reference. Repeat it twice, and rename the new queries NoBlanks and Blanks.
  3. In the NoBlanks query, apply a filter on the AA Trx Dimension ID column and remove empty values.
  4. In the Blanks query, apply a filter on the AA Trx Dimension ID and keep only the empty values.
  5. Remove the last two (and empty) columns of the Blanks query.
  6. If you don't have a unique key in your data, you would need to add to the NoBlanks query an Index column and then apply Divide-Integer on it to create a unique index for the multi-line records (See attached solution file in my last response). I also cover this technique in detail in Chapter 7 of my book "Collect, Combine & Transfer Data using Power Query in Excel and Power BI".
  7. Apply Pivot Column on the AA Trx Dimension ID  column of the NoBlanks query. In the advanced options of the Pivot Column, select Don't aggregate.
  8. Apply Append Queries As New on the Blanks and NoBlanks.

If you are not sure how to follow these instructions, please send me a sample report and I will attach the solution. 

 

Hi @DataChant 

 

Sorry I got stuck at the very last 2 steps I must have missed points of the reason of having reference table 

 

I have attached a sample for you below please let me know if that's good enough 

 

Audit Trail CodeVendor IDAA Debit AmountAA Credit AmountAA Assigned PercentAA Distribution ReferenceAA Trx Dimension IDAA Trx Dimension Code
PMTRN00002609AMBMA01175.600000.00000100.00000%   
PMTRN00002609ANAIS01339.000000.00000100.00000%   
PMTRN00002609PHILO01106.640000.00000100.00000%   
PMTRN00002610DYLHO012,130.910000.0000050.00000%Sample Text 1CLIENTMANG01
PMTRN00002610DYLHO012,130.910000.0000050.00000%Sample Text 1FUND SOURCETCP-PRO-01
PMTRN00002610DYLHO012,130.910000.0000050.00000%Sample Text 1CLIENTMANG02
PMTRN00002610DYLHO012,130.910000.0000050.00000%Sample Text 1FUND SOURCETCP-PRO-01
PMTRN00002610KICDR01383.350000.00000100.00000%Sample Text 2CLIENTKODI01
PMTRN00002610KICDR01383.350000.00000100.00000%Sample Text 2FUND SOURCEDHS-PCFA-01
PMTRN00002610VICBS01260.000000.00000100.00000%Sample Text 3CLIENTMAGO03
PMTRN00002610VICBS01260.000000.00000100.00000%Sample Text 3FUND SOURCEDHS-PCFA-01
PMTRN00002657VICBS01144.990000.0000033.00000%Sample Text 6CLIENTMAGO02
PMTRN00002657VICBS01144.990000.0000033.00000%Sample Text 6FUND SOURCEDHS-PCFA-01
PMTRN00002657VICBS01144.990000.0000033.00000%Sample Text 6CLIENTMAGO03
PMTRN00002657VICBS01144.990000.0000033.00000%Sample Text 6FUND SOURCEDHS-PCFA-01
PMTRN00002657VICBS01145.020000.0000033.00000%Sample Text 6CLIENTMAGO04
PMTRN00002657VICBS01145.020000.0000033.00000%Sample Text 6FUND SOURCEDHS-PCFA-01
DataChant
Most Valuable Professional
Most Valuable Professional

Hi @WLou,

I updated the instructions in my original reply. Hope it is clear now.

 

You can download the solution file in here:

Solution PBIX File 

Thanks so much @DataChant 

 

I was stucking at creating the index and Pivot

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.