• 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
    • 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
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Power Qwery to replace Filter + Large functions|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Power Qwery to replace Filter + Large functions|Power Query|Excel Forum|My Online Training Hub

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
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 QueryPower Qwery to replace Filter + Lar…
sp_PrintTopic sp_TopicIcon
Power Qwery to replace Filter + Large functions
Avatar
GH AR

New Member
Members
Level 0
Forum Posts: 2
Member Since:
January 4, 2023
sp_UserOfflineSmall Offline
1
January 4, 2023 - 1:04 pm
sp_Permalink sp_Print

Hello everyone,
I need your help to write a formula in Power Qwery
Attached is a table containing a list of Contact linked to customers. Some customers have several unique IDs
Here are the steps to do:
1. remove the customers with less than 5 employees
2. group the data by Contact and work for each Contact almost independently
3. for each Contact, identify a Customer ID that has the highest revenue among the other IDs of the same customer
If a Customer has only one ID, it is retrieved in this step
4. then among the remaining IDs, we recover the TOP2 Tot Revenue
The attached file shows the desired result and I'm looking for a solution in Power Qwery
To do so in Excel, I used a combination of 3 functions : IF+Filter+LARGE
Thank you in advance for your ideas

Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 382
Member Since:
January 31, 2022
sp_UserOnlineSmall Online
2
January 4, 2023 - 4:21 pm
sp_Permalink sp_Print

Please try to upload the file(s) again. This time, don't forget to press "Start upload" before you submit your reply.

Avatar
GH AR

New Member
Members
Level 0
Forum Posts: 2
Member Since:
January 4, 2023
sp_UserOfflineSmall Offline
3
January 5, 2023 - 3:41 am
sp_Permalink sp_Print sp_EditHistory

Hi,
Here is the file attached
Thanks

Avatar
Alan Sidman
Steamboat Springs, CO
Member
Members
Level 0
Forum Posts: 123
Member Since:
October 18, 2018
sp_UserOfflineSmall Offline
4
January 5, 2023 - 7:27 am
sp_Permalink sp_Print

With your table

let
Source = Excel.CurrentWorkbook(){[Name="Tbl_1"]}[Content],
#"Filtered Rows" = Table.SelectRows(Source, each [EmployeesNber] >= 5),
#"Grouped Rows" = Table.Group(#"Filtered Rows", {"Contact"}, {{"Max Revenue", each List.Max([Total Revenue]), type number}})
in
#"Grouped Rows"

Duplicate your table above and delete all steps except Source.

Then merge your two queries.

let
Source = Excel.CurrentWorkbook(){[Name="Tbl_1"]}[Content],
#"Merged Queries" = Table.NestedJoin(Source, {"Contact", "Total Revenue"}, Tbl_1, {"Contact", "Max Revenue"}, "Tbl_1", JoinKind.LeftOuter),
#"Expanded Tbl_1" = Table.ExpandTableColumn(#"Merged Queries", "Tbl_1", {"Contact", "Max Revenue"}, {"Tbl_1.Contact", "Tbl_1.Max Revenue"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Tbl_1", each ([Tbl_1.Contact] null)),
#"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"Total Revenue", Order.Descending}}),
#"Kept First Rows" = Table.FirstN(#"Sorted Rows",2)
in
#"Kept First Rows"

Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 382
Member Since:
January 31, 2022
sp_UserOnlineSmall Online
5
January 5, 2023 - 11:35 pm
sp_Permalink sp_Print

Thanks for uploading the file. Perhaps I misunderstood but I believe the attached file contains the solution that you are asking for. Let us know if that's not the case.
It creates a table line in the picture below, containing the 17 row you marked with "Y".

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 170
Currently Online: mymalone, Riny van Eekelen, Ivan Kulubya
Guest(s) 69
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1431
Anders Sehlstedt: 845
Velouria: 574
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 213
A.Maurizio: 202
Aye Mu: 201
Jessica Stewart: 185
Newest Members:
Vicky Otosnika
Abhishek Singh
Kevin Sojourner
Kara Weiss
And Woox
Armani Quenga
moshood bello
annelies b
James1989
lucy gilmour
Forum Stats:
Groups: 3
Forums: 24
Topics: 6045
Posts: 26523

 

Member Stats:
Guest Posters: 49
Members: 31492
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Riny van Eekelen
© Simple:Press —sp_Information
  • 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
 
  • About My Online Training Hub
  • Contact
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

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.

Download A Free Copy of 100 Excel Tips & Tricks

excel tips and tricks ebook

We respect your privacy. We won’t spam you.

x