Results 1 to 6 of 6

Running LET() function as a loop

Threaded View

  1. #1
    Registered User
    Join Date
    11-20-2022
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    3

    Running LET() function as a loop

    I have a long LET() function where I define a number of variable but with one of them being a range. Subsequently, I have a number of calculations which depend on the range but I want to make sure that all of the calculations are run fully with the first number in the range before the calculations are done again with the second number in the range. The formula works when calculating with a single number but not with the range. How can I solve this? (I don't have access to LAMBDA, SCAN etc. due to semi annual channel)

    Example:
    Range {1,3,5}
    when range=1, result=20
    when range=3, result=50
    when range=5, result=26

    So I want the result of the formula being {20,50,26}, how do I ensure this?

    Formula looks like this where I would like to run a loop for the second part based on the range from "peaks_position"


    =LET(
    Deficit_period,E26,
    Storage_beginning,H26,
    Price_period,F26,
    Hours,$D$6,
    deficit,OFFSET(Deficit_period,,,Hours),
    prices,OFFSET(Price_period,,,Hours),
    rows,SEQUENCE(Hours),
    peaks_position,FILTER(rows,(deficit>0)*(OFFSET(deficit,1,0)<=0)),
    
    
    rows_peak_position,SEQUENCE(ROWS(peaks_position)),
    no_rows_peak_position,SEQUENCE(peaks_position),
    rows_offset,rows-1,
    table_peaks_position,IF(rows,TRANSPOSE(peaks_position)),
    table_pp_na,table_peaks_position-rows_offset,
    table_peaks_position_relative,IFERROR(IF(table_pp_na<0,0,table_pp_na),0),
    storage_required,IFERROR(SUBTOTAL(9,OFFSET(Deficit_period,rows_offset,,table_peaks_position_relative)),0),
    binary_table_pp_relative,IF(table_peaks_position_relative>0,1,0),
    deficit_to_peak,IF(rows_peak_position,OFFSET(Deficit_period,,,peaks_position,)),
    deficit_to_peak_table,INDEX(IF(binary_table_pp_relative>0,deficit_to_peak,0),no_rows_peak_position),
    prices_to_peak,IF(rows_peak_position,OFFSET(Price_period,,,peaks_position,)),
    prices_to_peak_table,INDEX(IF(binary_table_pp_relative>0,prices_to_peak,0),no_rows_peak_position),
    Deficit_prices_table,IFERROR(INDEX(SORTBY(CHOOSE({1,2},deficit_to_peak_table,prices_to_peak_table),prices_to_peak_table,1,deficit_to_peak_table,-1),no_rows_peak_position,{1,2}),"N/A"),
    storage_required_peak,INDEX(storage_required,no_rows_peak_position),
    Deficit_sorted_by_p,INDEX(Deficit_prices_table,0,1),
    P_min,INDEX(Deficit_prices_table,0,2),
    ***_deficit,MMULT(IF(SEQUENCE(ROWS(Deficit_sorted_by_p))>=TRANSPOSE(SEQUENCE(ROWS(Deficit_sorted_by_p)))=TRUE,1,0),Deficit_sorted_by_p),
    P_min_no,IFERROR(XMATCH(-storage_required_peak,***_deficit,-1),XMATCH(SMALL(***_deficit,1),***_deficit,-1)),
    price_marginal,INDEX(P_min,P_min_no),
    To_storage,MIN(MAX(IF(price_marginal>=Price_period,storage_required_peak,0))+SUM(IF(prices_to_peak_table<Price_period,deficit_to_peak,0))-Storage_beginning,-Deficit_period),
    output,IF(To_storage<0,0,To_storage),
    
    output
    )
    Last edited by FDibbins; 11-21-2022 at 01:33 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Running a loop
    By jptierney in forum Excel General
    Replies: 4
    Last Post: 08-14-2021, 10:19 AM
  2. [SOLVED] Loop not running through
    By bk23 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-15-2019, 04:08 AM
  3. [SOLVED] Loop keeps running
    By jduong93 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-21-2016, 07:30 PM
  4. [SOLVED] Running Loop in an Array
    By Jiptastic in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2014, 06:15 PM
  5. Do loop not running
    By hattrick_123a in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-21-2011, 08:36 PM
  6. Loop not running
    By T De Villiers in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2006, 10:26 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1