• 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

Min, Max, Average or Sum variable number of columns|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Min, Max, Average or Sum variable number of columns|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 QueryMin, Max, Average or Sum variable n…
sp_PrintTopic sp_TopicIcon
Min, Max, Average or Sum variable number of columns
Avatar
Dave Green
Member
Members
Level 0
Forum Posts: 25
Member Since:
January 7, 2012
sp_UserOfflineSmall Offline
1
August 10, 2022 - 5:02 am
sp_Permalink sp_Print

Hi

The situation is I have a list of products with their prices. As time progresses prices ge updated via contract variations, and the new rates are added to a new column to the right of the products - this over time gives a history of the individual products. 

Note - not all products update at the same time, and they can be plus or minus from the original.

The issue is I need to do some calls based on the price history - i.e. what was the Max price or the Min, Average etc….

The column headers are chosen by the users so they may use something like Variation1, or 5/7/2022 or Summer22 - so basically no regular values.

How then can I find all  the columns with pricing (lets say I know the first two columns are and index, and the product), and carry out the necessary calculations?

Im on a train at the moment using my phone so cannot upload a workbook until later, if that would help.

Thanks in advance for any comments

GreenBoy

sp_AnswersTopicSeeAnswer See Answer
Avatar
Alan Sidman
Steamboat Springs, CO
Member
Members


Trusted Members
Level 0
Forum Posts: 132
Member Since:
October 18, 2018
sp_UserOfflineSmall Offline
2
August 10, 2022 - 1:20 pm
sp_Permalink sp_Print

 A Workbook would be very handy.  I am guessing that your data should be normalized by unpivoting your table and doing a Group By on the products to find the Min, Max and Average.

Avatar
Dave Green
Member
Members
Level 0
Forum Posts: 25
Member Since:
January 7, 2012
sp_UserOfflineSmall Offline
3
August 13, 2022 - 9:42 pm
sp_Permalink sp_Print

Hi Alan

Sorry for the delay in responding - the holiday season seems to make everything busier... 

Please see a sample sheet below (cant add files to this forum)

I have played with pivoting and unpivoting... but I am obviously missing something.

 

Any help gratefully received.

Thanks

GreenBoy

Product ID        Product                                                           Unit                        Rate               Var 1                 RPI                        Var 2

1 Widget Nr 100 98 102.9 105
2 Metric Widget Nr 80 83 87.15 85
3 Boxes Nr   25 26.25 30
4 Meters m 17 17 17.85 18
Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 440
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
4
August 13, 2022 - 10:49 pm
sp_Permalink sp_Print sp_EditHistory

Hi Dave,

Copied your example in a empty sheet and played around with PQ a bit. Perhaps that's what you had in mind. All it does is unpivot all columns except for the first three (ID, Product and Unit). Then you can group by ID with three separate aggregations (min, max and average).

By the way, you can upload files here. Befor you press "Submit Reply"  press "Attachments" at the far left-hand side of the editor window. Select the file(s) "Add File"  and then press "Start Upload".

If I missed the point completely, try uploading a file again and include what you have tried so far and what you would want as the end result.

 

Riny

sp_AnswersTopicAnswer
Answers Post
Avatar
Dave Green
Member
Members
Level 0
Forum Posts: 25
Member Since:
January 7, 2012
sp_UserOfflineSmall Offline
5
August 13, 2022 - 11:07 pm
sp_Permalink sp_Print

Riny - thank you, this is absolutely spot on.

I think merging the table with itself is amazing.

Thank you again.

David

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


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 440
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
6
August 13, 2022 - 11:51 pm
sp_Permalink sp_Print

Glad I could help, and indeed, I forgot to mention that merging the table with itself was the third important step in the process. 

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Roslyn Finlayson
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Naomi Rumble
Uwe von Gostomski
Jonathan Jones
drsven
Forum Stats:
Groups: 3
Forums: 24
Topics: 6210
Posts: 27236

 

Member Stats:
Guest Posters: 49
Members: 31888
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.