PowerQuery

%3CLINGO-SUB%20id%3D%22lingo-sub-1613309%22%20slang%3D%22en-US%22%3EPowerQuery%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1613309%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20-%20thanks%20for%20taking%20the%20time%20to%20look%20at%20my%20question.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20very%20familiar%20with%20Excel's%20front%20end%20and%20formulae%20but%20have%20recently%20started%20exploring%20PowerQuery.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEverything%2C%20I%20want%20to%20achieve%2C%20I%20can%20do%20using%20Excel's%20formula%20options%26nbsp%3B%3CSTRONG%3EBUT%3C%2FSTRONG%3E%2C%20I%20was%20wondering%20if%20I%20could%20do%20the%20same%20thing%20in%20PQ.%20If%20so%20how%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20couple%20of%20tables.%20The%20main%20table%20contains%20product%20data%20and%20a%20small%205%20row%20table%20contains%20packaging%20data.%20Essentially%2C%20I%20am%20comparing%20the%20product%20dimensions%20against%20the%20packaging%20limits%20and%20it%20the%20product%20fits%20a%20pack%20type%20then%20return%20that.%3C%2FP%3E%3CP%3EWhen%20I%20first%20excitedly%20jumped%20over%20to%20PQ%2C%20it%20soon%20became%20clear%20without%20a%20direct%20relationship%20and%20the%20knowledge%20of%20if%2Fhow%20to%20cross%20reference%20I%20was%20lost.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20advice%20or%20just%20a%20plain%20%22can't%20be%20done%22%20would%20be%20great.%20Thanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOli%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1613309%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBI%20%26amp%3B%20Data%20Analysis%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1613406%22%20slang%3D%22en-US%22%3ERe%3A%20PowerQuery%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1613406%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F602317%22%20target%3D%22_blank%22%3E%40DEADP00L%3C%2FA%3E%26nbsp%3BThe%20reasoning%20process%20when%20using%20Excel%20formulas%20is%20different%20than%20when%20using%20power%20Query.%20Whilst%20with%20the%20formulas%20you%20can%20work%20on%20a%20cell%20by%20cell%20case%2C%20Power%20Query%20is%20mostly%20used%20to%20work%20at%20the%20column%20level.%20It%20is%20possible%20to%20act%20at%20the%20%22cell%22%20level%20but%20it%20knowledge%20of%20M%20code%20language.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20being%20said%2C%20you%20might%20still%20be%20able%20to%20use%20Power%20Query%20to%20solve%20your%20problem%20without%20having%20to%20modify%20the%20M%20code%20that%20PQ%20generates%20on%20each%20step.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETow%20questions%20for%20you%3A%3C%2FP%3E%3CP%3E1%20-%20Why%20would%20you%20want%20to%20use%20PQ%20instead%20of%20the%20formulas%20that%20you%20have%20working%20in%20Excel%20already%3F%26nbsp%3B%3C%2FP%3E%3CP%3E2%20-%20What%20are%20the%20formulas%20that%20you%20are%20currently%20using%3F%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20are%20using%20VLOOKUP%20with%20TRUE%20argument%2C%20take%20a%20look%20at%20this%20video%20and%20see%20if%20it%20helps.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DEYgKciBr_dg%26amp%3Bt%3D217s%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DEYgKciBr_dg%26amp%3Bt%3D217s%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1613439%22%20slang%3D%22en-US%22%3ERe%3A%20PowerQuery%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1613439%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F602317%22%20target%3D%22_blank%22%3E%40DEADP00L%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'd%20recommend%20this%20resource%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fresources-and-community%2Fmodern-excel-webinar-advanced-data-preparation-techniques-with%2Fm-p%2F1492537%22%20target%3D%22_self%22%3EModern%20Excel%20webinar%3A%20Advanced%20Data%20Preparation%20Techniques%20with%20Power%20Query%3C%2FA%3E%26nbsp%3Bfrom%20Ken%20Puls.%20Independently%20of%20skills%20level%20in%20Power%20Query%20it'll%20be%20very%20useful.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1613465%22%20slang%3D%22en-US%22%3ERe%3A%20PowerQuery%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1613465%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F602317%22%20target%3D%22_blank%22%3E%40DEADP00L%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%20it%20possible%2C%20please%20share%20the%20same%20data%20to%20advise%20you%20the%20right%20solution%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ERegards%2C%20Faraz%20Shaikh%20%7C%20MCT%2C%20MIE%2C%20MOS%20Master%2C%20Excel%20Expert%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CEM%3E%3CFONT%20color%3D%22%23808080%22%3EIf%20you%20find%20the%20above%20solution%20resolved%20your%20query%20don't%20forget%20mark%20as%26nbsp%3B%3CSPAN%3EOfficial%2FBest%20Answer%26nbsp%3Bto%20help%20the%20other%20members%20find%20it%20more%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1615620%22%20slang%3D%22en-US%22%3ERe%3A%20PowerQuery%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1615620%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F302344%22%20target%3D%22_blank%22%3E%40Celia_Alves%3C%2FA%3E%26nbsp%3BThank%20you%20for%20your%20reply%20and%20the%20link%20to%20Oz's%20video.%20Great%20stuff.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20initial%20reasoning%20to%20use%20PQ%20was%20to%20try%20and%20push%20as%20much%20of%20the%20computation%20into%20the%20back-end.%20Now%20that%20I%20have%20completed%20it%20I%20would%20still%20like%20to%20learn%20'for%20next%20time'.%26nbsp%3B%3C%2FP%3E%3CP%3E%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20sort%20of%20formulas%20I%20am%20using%20are%20quite%20standard%20and%20I%20have%20used%20named%20formulas%20to%20improve%20readability.%20some%20examples%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3Epackaging.cost%20%20%3DIF(HasNoDimensionData%2C%22%22%2CSWITCH(packaging.use%2CPackType1%2CPackType1.Cost%2CPackType2%2CPackType2.Cost%2CPackType3%2CPackType3.Cost%2CPackType4%2CPackType4.Cost%2CPackType5%2CPackType5.Cost%2CPackType6%2CPackType6.Cost%2CPackType7%2CPackType7.Cost))%3C%2FCODE%3E%3C%2FPRE%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3Epackaging.type%20%20%3DIF(%0A%20%20%20AND(Stock_Details%5B%40%5BMin%20Dimension%5D%5D%3CPACKTYPE1.DIMENSIONMIN%3E%3C%2FPACKTYPE1.DIMENSIONMIN%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPackType1.Cost%20%20%3DINDEX(Packaging%5BCost%5D%2CPackType1.index)%3C%2FCODE%3E%3C%2FPRE%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EPackagingType1.index%20%3DMATCH(PackType1%2CPackaging%5BType%5D%2C0)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22DEADP00L_0-1598518526596.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F214944i45F05C3B66E76858%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22DEADP00L_0-1598518526596.png%22%20alt%3D%22DEADP00L_0-1598518526596.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1619436%22%20slang%3D%22en-US%22%3ERe%3A%20PowerQuery%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1619436%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F602317%22%20target%3D%22_blank%22%3E%40DEADP00L%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EQuite%20impressive.%20It%20is%20not%20easy%20to%20add%20those%20long%20formulas%20to%20the%20names%20manager.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi - thanks for taking the time to look at my question.

 

I am very familiar with Excel's front end and formulae but have recently started exploring PowerQuery.

 

Everything, I want to achieve, I can do using Excel's formula options BUT, I was wondering if I could do the same thing in PQ. If so how?

 

I have a couple of tables. The main table contains product data and a small 5 row table contains packaging data. Essentially, I am comparing the product dimensions against the packaging limits and it the product fits a pack type then return that.

When I first excitedly jumped over to PQ, it soon became clear without a direct relationship and the knowledge of if/how to cross reference I was lost.

 

Any advice or just a plain "can't be done" would be great. Thanks

 

Oli

 

5 Replies
Highlighted

@DEADP00L The reasoning process when using Excel formulas is different than when using power Query. Whilst with the formulas you can work on a cell by cell case, Power Query is mostly used to work at the column level. It is possible to act at the "cell" level but it knowledge of M code language.

 

That being said, you might still be able to use Power Query to solve your problem without having to modify the M code that PQ generates on each step. 

 

Tow questions for you:

1 - Why would you want to use PQ instead of the formulas that you have working in Excel already? 

2 - What are the formulas that you are currently using? 

If you are using VLOOKUP with TRUE argument, take a look at this video and see if it helps.

https://www.youtube.com/watch?v=EYgKciBr_dg&t=217s

 

So, we've got a discount grid and need to assign the right price to various amounts. Then, you want to add tiers or change the levels. VLOOKUP-True is what y...
Highlighted

@DEADP00L 

I'd recommend this resource Modern Excel webinar: Advanced Data Preparation Techniques with Power Query from Ken Puls. Independently of skills level in Power Query it'll be very useful.  

Highlighted

Hi @DEADP00L 

 

Yes it possible, please share the same data to advise you the right solution 

 

Regards, Faraz Shaikh | MCT, MIE, MOS Master, Excel Expert

If you find the above solution resolved your query don't forget mark as Official/Best Answer to help the other members find it more

 

 

 

Highlighted

@Celia_Alves Thank you for your reply and the link to Oz's video. Great stuff.

 

My initial reasoning to use PQ was to try and push as much of the computation into the back-end. Now that I have completed it I would still like to learn 'for next time'. 

 

The sort of formulas I am using are quite standard and I have used named formulas to improve readability. some examples:

packaging.cost		=IF(HasNoDimensionData,"",SWITCH(packaging.use,PackType1,PackType1.Cost,PackType2,PackType2.Cost,PackType3,PackType3.Cost,PackType4,PackType4.Cost,PackType5,PackType5.Cost,PackType6,PackType6.Cost,PackType7,PackType7.Cost))
packaging.type		=IF(
			AND(Stock_Details[@[Min Dimension]]<PackType1.DimensionMin,Stock_Details[@[Median Dimension]]<PackType1.DimensionMedian,Stock_Details[@[Max Dimension]]<PackType1.DimensionMax),PackType1,IF(
			AND(Stock_Details[@[Min Dimension]]<PackType2.DimensionMin,Stock_Details[@[Median Dimension]]<PackType2.DimensionMedian,Stock_Details[@[Max Dimension]]<PackType2.DimensionMax),PackType2,IF(
			AND(Stock_Details[@[Min Dimension]]<PackType3.DimensionMin,Stock_Details[@[Median Dimension]]<PackType3.DimensionMedian,Stock_Details[@[Max Dimension]]<PackType3.DimensionMax),PackType3,IF(
			AND(Stock_Details[@[Min Dimension]]<PackType4.DimensionMin,Stock_Details[@[Median Dimension]]<PackType4.DimensionMedian,Stock_Details[@[Max Dimension]]<PackType4.DimensionMax),PackType4,IF(
			AND(Stock_Details[@[Min Dimension]]<PackType5.DimensionMin,Stock_Details[@[Median Dimension]]<PackType5.DimensionMedian,Stock_Details[@[Max Dimension]]<PackType5.DimensionMax),PackType5,IF(
			AND(Stock_Details[@[Min Dimension]]<PackType6.DimensionMin,Stock_Details[@[Median Dimension]]<PackType6.DimensionMedian,Stock_Details[@[Max Dimension]]<PackType6.DimensionMax),PackType6,IF(
			AND(Stock_Details[@[Min Dimension]]<PackType7.DimensionMin,Stock_Details[@[Median Dimension]]<PackType7.DimensionMedian,Stock_Details[@[Max Dimension]]<PackType7.DimensionMax),PackType7, "No")))))))
PackType1.Cost		=INDEX(Packaging[Cost],PackType1.index)
PackagingType1.index	=MATCH(PackType1,Packaging[Type],0)

DEADP00L_0-1598518526596.png

 

 

Highlighted

@DEADP00L 

Quite impressive. It is not easy to add those long formulas to the names manager.