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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
DanieleX
Regular Visitor

Power Query VlookUp or another way?

Hello all,

I'm pretty new to PowerBi, I'm looking to manipulate the data in Power Query to have a result where the Order-ID will be my unique id to put into relation with other tables.

I have this initial data sample with the amounts for the same order split into multiple lines depending on the descriptions. 

 

order-idamount-typeamount-descriptionamount
302-8280724-3255530ItemPricePrincipal172,12
302-8280724-3255530ItemPriceTax32,7
302-8280724-3255530ItemFeesCommission-21,43
305-1931380-0225167ItemPricePrincipal106,55
305-1931380-0225167ItemPriceTax20,24
305-1931380-0225167ItemFeesCommission-14,41
305-3602247-3812336ItemPricePrincipal57,38
305-3602247-3812336ItemPriceTax12,05
305-3602247-3812336ItemFeesCommission-9,25


The result I'm looking for is something like this:

order-idamount-typePrincipal AmmountTax AmmountCommission Ammount
302-8280724-3255530ItemPrice172,1232,7-21,43
305-1931380-0225167ItemPrice106,5520,24-14,41
305-3602247-3812336ItemPrice57,3812,05-9,25


Thanks for your help

1 ACCEPTED SOLUTION

@DanieleX,

I believe the reason "Commission" is showing up on a different line, is because the AmountType is different.

In Power Query, use the ReplaceValues to change ItemFees to ItemPrice

Then Pivot your AmountType

Then Pivot AmountDescription

 

 #"Replaced Value" = Table.ReplaceValue(Source,"ItemFees","ItemPrice",Replacer.ReplaceText,{"amount-type"}),
    #"Pivoted Column" = Table.Pivot(#"Replaced Value", List.Distinct(#"Replaced Value"[#"amount-type"]), "amount-type", "amount"),
    #"Pivoted Column1" = Table.Pivot(#"Pivoted Column", List.Distinct(#"Pivoted Column"[#"amount-description"]), "amount-description", "ItemPrice")
in
    #"Pivoted Column1"

Using these steps in PQ, I get the following result.  I hope this is what you are looking for:

rsbin_0-1639685591541.png

 

View solution in original post

4 REPLIES 4
DanieleX
Regular Visitor

Hello Amitchandak,

Thank you for your answer.

Unpivot on amount-description & amount column doesn't create a result that I need.

I tried Pivot, without aggregate that it almost give me my result.
The only problem is that Commission is on a different line

DanieleX_0-1639676820661.png

 

@DanieleX,

I believe the reason "Commission" is showing up on a different line, is because the AmountType is different.

In Power Query, use the ReplaceValues to change ItemFees to ItemPrice

Then Pivot your AmountType

Then Pivot AmountDescription

 

 #"Replaced Value" = Table.ReplaceValue(Source,"ItemFees","ItemPrice",Replacer.ReplaceText,{"amount-type"}),
    #"Pivoted Column" = Table.Pivot(#"Replaced Value", List.Distinct(#"Replaced Value"[#"amount-type"]), "amount-type", "amount"),
    #"Pivoted Column1" = Table.Pivot(#"Pivoted Column", List.Distinct(#"Pivoted Column"[#"amount-description"]), "amount-description", "ItemPrice")
in
    #"Pivoted Column1"

Using these steps in PQ, I get the following result.  I hope this is what you are looking for:

rsbin_0-1639685591541.png

 

That's solved the issue. Thanks!

amitchandak
Super User
Super User

@DanieleX , Unpivot last 2 columns

https://radacad.com/pivot-and-unpivot-with-power-bi


Unpivot Data(Power Query) https://www.youtube.com/watch?v=2HjkBtxSM0g&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=11

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors