• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Select a field|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Select a field|Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QuerySelect a field
sp_PrintTopic sp_TopicIcon
Select a field
Avatar
andrea alfano

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
October 18, 2019
sp_UserOfflineSmall Offline
1
October 22, 2019 - 8:21 am
sp_Permalink sp_Print
Hi everyone,

which is the formula that given a table like
PRODUCT
QUANTITY
A
10
B
20
C
15
Allow me to pass the product as parameter so to have the quantity as result

So if for example, I pass “B” as parameter the formula give 20 as result.

Thank you very much for the help.
Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1810
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
2
October 22, 2019 - 2:05 pm
sp_Permalink sp_Print

You should merge the data table with that Loookup table you described above, I guess you have a Product column in your data table, use the Product columns from both tables as keys.

Then you just have to expand the Quantity column.

let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
#"Merged Queries" = Table.NestedJoin(Source, {"Product"}, LookupTable, {"Product"}, "LookupTable", JoinKind.LeftOuter),
#"Expanded LookupTable" = Table.ExpandTableColumn(#"Merged Queries", "LookupTable", {"Quantity"}, {"Quantity"})
in
#"Expanded LookupTable"

Avatar
andrea alfano

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
October 18, 2019
sp_UserOfflineSmall Offline
3
October 22, 2019 - 5:44 pm
sp_Permalink sp_Print

Thank you so much Catalin.

Instead of join, I'd like to use a function (such as record.select or field.select), passing to the function a parameter and the parameter will be the product.

Is there any way?

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1810
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
4
October 22, 2019 - 10:45 pm
sp_Permalink sp_Print sp_EditHistory

It is possible, but it will be slower, is there a reason for that preference?

You can convert the lookup table to a custom function, replace the name of the query with: LookupTable (this will be the name of the new function).

(Product)=>
let
Source = Excel.CurrentWorkbook(){[Name="LookupTable"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"Quantity", Int64.Type}}),
#"Filtered Rows" = try Table.SelectRows(#"Changed Type", each ([Product] = Product)){0}[Quantity] otherwise null
in
#"Filtered Rows"

In the Data query, you can add a new column with a simple formula using the new custom function, passing the product as a parameter:

=LookupTable([Product])

Avatar
andrea alfano

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
October 18, 2019
sp_UserOfflineSmall Offline
5
October 22, 2019 - 11:31 pm
sp_Permalink sp_Print

The problem that I’m trying to solve sound like:

Estimate the quantity sales of product via the quantity sales of other product.

So If I have a table for sales like:

PRODUCT QUANTITY
CAR 10

 

And I know that for each CAR sold I will sell also 4 TYRE and for each TYRE 4 BOLT

So I have a table like:

PRODUCT PRODUCT RELATED RULES
CAR TYRE *4
TYRE BOLT *4

 

I want to produce another table like

PRODUCT RELATED QUANTITY
TYRE 40
BOLT 160

Is there a solution in PQ?

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Valentyn Kristioglo, Tiffany Kang, stuart burge
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 205
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
stuart burge
Bruce Tang Nian
Scot C
Othman AL MUTAIRI
Misael Gutierrez Sr.
Attif Ihsan
Kieran Fee
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Forum Stats:
Groups: 3
Forums: 24
Topics: 6223
Posts: 27294

 

Member Stats:
Guest Posters: 49
Members: 31919
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.