1

I am uploading Calendar Events in Oracle Fusion. The events went fine, but I am now working on assigning the coverage which is set by country in our setup.

My coverage source data (this is sample of it), delivered by a colleagues is structured as:

Short Code2 Name2 NL DE GB FR LU ES AU CA CL US FI
NYD1-23 New Year's Day 2023 x x x x x x
NYD2-23 New Year's Holiday 2023 x x x x x
EP-23 Epiphany 2023 x x
MLK-23 Martin Luther King Day 2023 x
ADH-23 Australia Day Holiday 2023 x
LB-23 Lincoln's Birthday 2023 x
PRES-23 Presidents' Day 2023 x
ADH-23 Family Day 2023 x
STJ-23 Saint Josephs day 2023 x
EAT-23 Easter Thursday 2023 x

I could alter the data, to include helper columns or anything that would make the task easier.

What Oracle needs in the uploadsheet for coverage is the following format:

Short Code Coverage Node Coverage
NYD1-23 NL I
NYD1-23 DE I
NYD1-23 FR I
NYD1-23 LU I
NYD1-23 ES I
NYD1-23 FI I
NYD2-23 GB I
NYD2-23 AU I
NYD2-23 CA I
NYD2-23 CL I
NYD2-23 US I

etc.

So the Short Code needs to be repeated on each row, for the amount of x's that are on the row. The country codes need to each be on a separate row and the third column is always I (for include).

So far, I've been wrecking my brain with MOD, ARRAY, TRANSPOSE and FILTER functions in Excel but I think I'm going about it the wrong way. There must be an easier solution that I am not seeing.

I'm using Excel on 365. (Version 2202 Build 16.0.14931.20858)

Help much appreciated.

Ike
  • 9,580
  • 4
  • 13
  • 29
MaartenB
  • 31
  • 4
  • Please provide your data via [Markdown Table Generator](https://www.tablesgenerator.com/markdown_tables) (read [this](https://meta.stackoverflow.com/a/285557/16578424) for an explanation). It makes it much easier to help you. – Ike Jan 13 '23 at 15:27
  • 1
    Updated the tables to the markdown format. – MaartenB Jan 13 '23 at 16:02

1 Answers1

2

I created a table (insert > table) from your data and called it "data".

You can use this formula:

=LET(cntCountries,COLUMNS(data),
cntRows, ROWS(data)*cntCountries,

shortCodeByRowλ,LAMBDA(r,INT((r-1)/cntCountries)+1),
countryCodesByRowλ,LAMBDA(r,MOD(r-1,cntCountries)+1),

shortcodes,MAKEARRAY(cntRows,1,LAMBDA(r,c,INDEX(data[Short Code2],shortCodeByRowλ(r)))),
countrycodes,MAKEARRAY(cntRows,1,LAMBDA(r,c,INDEX(data[#Headers],1,countryCodesByRowλ(r)))),
selection,SUBSTITUTE(MAKEARRAY(cntRows,1,LAMBDA(r,c,INDEX(data,shortCodeByRowλ(r),countryCodesByRowλ(r)) )),"x","I"),

FILTER(HSTACK(shortcodes,countrycodes,selection),selection="I"))

The basic idea is to create each column based on MAKEARRAY. The values are each retrieved based on the row of the new array - either from the short code column or from the header country codes. --> using the two LAMBDA-functions.

for the result the HSTACKEd array is filter for the I rows.

There are two lambdas to retrieve either the short code or the country code for the row.

enter image description here

Ike
  • 9,580
  • 4
  • 13
  • 29
  • Hi Ike, thanks a lot for taking the time to answer. I have been trying to get results in the way that you do, but I just couldn't get there. Looks like a good solution. Changed my table name to 'data', but I am getting an error when I try to input your formula. Excel's compiler sends me to the first 'r' on the third row. It doesn't seem to recognize the LAMBDA formula. – MaartenB Jan 16 '23 at 12:22
  • Then you don't have the current channel of Excel 365 and can't use the LAMBDA-function :-( (Most likely you don't have HSTACK as well ...) You could replace the individual Lambda calls by the formula - but it will get pretty messy then. – Ike Jan 16 '23 at 13:06
  • 1
    You are correct. Also don't have the HSTACK function. I will see if I can hack together the formulas for the three columns separately. Want to thank you for pushing me in the right direction. Will mark it as answer when I have completed the task. – MaartenB Jan 16 '23 at 13:59
  • 1
    Hey Ike, just wanted to let you know that I now have the LAMBDA function available and was able to use your script for the 2024 run. Thanks again! – MaartenB Jun 12 '23 at 07:38