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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
JK07
New Member

Pivot multiple value types and KPIs

Dear PBI Community,

 

Im trying to pivot some column in POwer BI query to transform the data and have extra column created with the combination of Value type and column with sotred values.
The initial data looks following:

 

IDAttribute 1Attribute 2Attribute 3Attribute 4Attribute 5Attribute 6Value typeCompany PartVendor PartSystem
Aattribute 1bttribute 1cttribute 1dttribute 1ettribute 1fttribute 1Actual100200300
Aattribute 1bttribute 1cttribute 1dttribute 1ettribute 1fttribute 1Budget2393116
Aattribute 1bttribute 1cttribute 1dttribute 1ettribute 1fttribute 1Commitment839881071
Aattribute 1bttribute 1cttribute 1dttribute 1ettribute 1fttribute 1On hold12234561679
Battribute 2bttribute 2cttribute 2dttribute 2ettribute 2fttribute 2Actual1233387413207
Battribute 2bttribute 2cttribute 2dttribute 2ettribute 2fttribute 2Budget13449485796201
Battribute 2bttribute 2cttribute 2dttribute 2ettribute 2fttribute 2Commitment21349487497008
Battribute 2bttribute 2cttribute 2dttribute 2ettribute 2fttribute 2On hold4988948414472
Cattribute 3bttribute 3cttribute 3dttribute 3ettribute 3fttribute 3Actual394859539580
Cattribute 3bttribute 3cttribute 3dttribute 3ettribute 3fttribute 3Budget49338499454332
Cattribute 3bttribute 3cttribute 3dttribute 3ettribute 3fttribute 3Commitment39488499344481
Cattribute 3bttribute 3cttribute 3dttribute 3ettribute 3fttribute 3On hold488223293781759
Dattribute 4bttribute 4cttribute 4dttribute 4ettribute 4fttribute 4Actual822948210304
Dattribute 4bttribute 4cttribute 4dttribute 4ettribute 4fttribute 4Budget2884239929241
Dattribute 4bttribute 4cttribute 4dttribute 4ettribute 4fttribute 4Commitment8382308763846993
Dattribute 4bttribute 4cttribute 4dttribute 4ettribute 4fttribute 4On hold59958766293657

 

Expected outcome as below:

IDAttribute 1Attribute 2Attribute 3Attribute 4Attribute 5Attribute 6Actual CompanyBudget CompanyCommitment CompanyOn Hold CompanyActual VendorBudget VendorCommitment VendorOn Hold VendorActual SystemBudget SystemCommitment SystemOn Hold System
Aattribute 1bttribute 1cttribute 1dttribute 1ettribute 1fttribute 1100238312232009398845630011610711679
B
C
D
E


Appreciate support.

 

1 ACCEPTED SOLUTION

Hi @JK07 ,

You are right.  Apologies for that, and instead of using the fill up, you can use Groupby function in Power Query to restructure the table like below:

DataNinja777_0-1724920285632.png

The above was prepared by clicking the ribbon for each new column one at a time, but there might be a more efficient way to do this, even for the initial setup.

I have attached the PBIX file for your reference.

 

View solution in original post

6 REPLIES 6
DataNinja777
Super User
Super User

Hi @JK07 ,

 

You can rearrange your data in your desired format using Power Query by following these steps:

  1. Pivot the [Value type] column: This will create separate columns for each value type ("Actual," "Budget," "Commitment," and "On hold") with 1s and 0s indicating their presence.

 

= Table.Pivot(#"Changed Type1", List.Distinct(#"Changed Type1"[#"Value type"]), "Value type", "ID", List.Count)

 

 

DataNinja777_1-1724714018598.png

 

  1. Add columns: Multiply the original value columns by the newly created columns of 1s and 0s for each value type to place the values in the appropriate columns. This process requires repetitive work, and there might be more efficient methods than manually adding a custom column for each combination of value type and value one by one.
  2. Replace 0s with nulls: In the new columns containing values, replace 0s with nulls, and use the fill-up feature to propagate the values.
  3. Filter for First Occurrence: In the value type field, filter for the first occurrence of 1 in the top row to remove duplicates.
  4. The final output: Your data will be rearranged as shown below.

 

DataNinja777_0-1724713878224.png

These steps can be performed by clicking the Power Query ribbons.

 

Best regards,

Hi @DataNinja777 

Thanks, I stuck on #3 and filtering. Can you please explain more how to do it and keep all populated values in each column?

JK07_0-1724838331656.png

Best,

Hi @JK07 ,

 

1. Select the Column: Click on the column header that contains the values you want to fill up.

2. Go to the Transform tab: In the Power Query Editor, navigate to the Transform tab in the ribbon.

3. Use the Fill option:

  • In the Transform tab, look for the Fill button. It is usually located in the Any Column group.
  • Click on the drop-down arrow next to the Fill button.
  • You will see two options: Fill Down and Fill Up.
  • Select Fill Up.

4. Apply Changes: Once you select Fill Up, Power Query will fill the empty cells in the selected column by propagating the nearest non-empty value upwards. 

5. To retain only the non-duplicate rows, select the 'Budget' column and filter for the value '1'. This works because the 'Budget' column has a '1' in the top row, and we are using the Fill Up feature to propagate values. By filtering for '1' in the 'Budget' column, we ensure that only non-duplicate rows are kept.

 

Best regards,

@DataNinja777 hi,

Thanks, It seems it doesnt work for last ID (D). After filtering I get null in Actuals, same in On Hold, etc.

JK07_0-1724855976465.png

Also ID C should have 39585 in Actual Company while it gets 822 (so ID D value)

Best,

 

Hi @JK07 ,

You are right.  Apologies for that, and instead of using the fill up, you can use Groupby function in Power Query to restructure the table like below:

DataNinja777_0-1724920285632.png

The above was prepared by clicking the ribbon for each new column one at a time, but there might be a more efficient way to do this, even for the initial setup.

I have attached the PBIX file for your reference.

 

@DataNinja777 
Perfect!
Thank you very much!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.