• 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

CHOOSE function with a variable number of choices?|General Excel Questions & Answers|Excel Forum|My Online Training Hub

You are here: Home / CHOOSE function with a variable number of choices?|General Excel Questions & Answers|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 ForumGeneral Excel Questions & Answe…CHOOSE function with a variable num…
sp_PrintTopic sp_TopicIcon
CHOOSE function with a variable number of choices?
Avatar
George Antony

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
December 25, 2020
sp_UserOfflineSmall Offline
1
December 25, 2020 - 11:31 pm
sp_Permalink sp_Print

Hi All,

    Ever since the new Dynamic Arrays were released, I've been trying to make my calculations use the spill functionality as much as I can. I've been stuck on this one for a while now and thought I'd reach out to see if anyone has a solution. 

    I'm trying to fit a trend line using the SLOPE and INTERCEPT functions. They both accept two arguments like this : SLOPE(C2:C52,B2:B52) / INTERCEPT(C2:C52,B2:B52) where column C contains the Y values and column D contains the X values. Works great. 

    I have multiple X value ranges (in columns D, E, F, ...). The number of columns can vary so I want to make it dynamic. SLOPE(C2:F52,B2:B52) will fail since SLOPE is expecting a one dimensional range. I got around this by using the CHOOSE function like this: 

CHOOSE({1,2,3},SLOPE(C2:C52,B2:B52),SLOPE(D2:D52,B2:B52),SLOPE(F2:F52,B2:B52))

This does 3 columns perfectly. How do I make it so that I can send a variable number of items (could be a lot of columns, so typing them in is not a great option) into the CHOOSE function. The first part is easy with the SEQUENCE function. I'm stuck on the second part. Any help would be appreciated. 

Thanks,

George.

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 412
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
2
December 26, 2020 - 6:06 am
sp_Permalink sp_Print

can you upload an example worksheet so we dont have to try and recreate the data

Avatar
George Antony

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
December 25, 2020
sp_UserOfflineSmall Offline
3
December 26, 2020 - 6:43 am
sp_Permalink sp_Print

Here's a sample workbook. Thanks for helping.

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 412
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
4
December 27, 2020 - 10:58 pm
sp_Permalink sp_Print

Probably not what you are after, but.....

I used the offset function to get the next column, but it does need a number to offset by. I couldnt get th sequence function to work within the offset (guessing it doesnt support arrays, but not had a chance to check). So i took the number from the header row

You still have to drag the formula over but it seems to work

Avatar
Fluff
Member
Members
Level 0
Forum Posts: 31
Member Since:
July 31, 2020
sp_UserOfflineSmall Offline
5
December 28, 2020 - 12:36 am
sp_Permalink sp_Print

Once again probably not quite what you want, but two options.

1) if you have the LET function

=LET(Rng,B2:G47,CHOOSE(SEQUENCE(,COUNT(B2:G2)),SLOPE(INDEX(Rng,,1),A2:A47),SLOPE(INDEX(Rng,,2),A2:A47),SLOPE(INDEX(Rng,,3),A2:A47),SLOPE(INDEX(Rng,,4),A2:A47),SLOPE(INDEX(Rng,,5),A2:A47),SLOPE(INDEX(Rng,,6),A2:A47)))

2) A formula that doesn't spill

=SLOPE(FILTER($B$2:$G$47,$B$1:$G$1=J6),$A$2:$A$47)

Avatar
George Antony

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
December 25, 2020
sp_UserOfflineSmall Offline
6
December 28, 2020 - 3:22 am
sp_Permalink sp_Print

Thank you Purfleet and Fluff. I'll try your solutions.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Scott Miller, Roy Lutke, Jeff Krueger, Darrell Hodge, Francisco Luna
Guest(s) 10
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: 6212
Posts: 27236

 

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