0

I have a column that has dates and right next to it, I have another column that has a number. What I want to do is write formula in excel that will create a new list that has each date repeated the exact number of times. See below for example:

Column A Nov-22 Dec-22 Jan-23 Column B 2 2 1

New Column:

Nov-22 Nov-22 Dec-22 Dec-22 Jan-23

2 Answers2

1

FILTERXML() with REPT() function may give you desired result.

=TEXT(FILTERXML("<t><s>"&TEXTJOIN("",TRUE,REPT(A1:A3&"</s><s>",B1:B3))&"</s></t>","//s[node()]"),"mmm-yy")

Read this to know more about FILTERXM() by JvdV.

enter image description here

Harun24hr
  • 30,391
  • 4
  • 21
  • 36
0

Another approach requiring Office 365, but not limited to Windows environment (like FILTERXML):

=LET(data,A1:B3,
          month,INDEX(data,,1),
          freq,INDEX(data,,2),
          seq,SEQUENCE(SUM(freq)),
          cum,SCAN(0,freq,LAMBDA(a,b,a+b)),
INDEX(month,XMATCH(seq,cum,1)))

It indexes the data to month and frequency, then it indexes the month to the closest (exact or next larger) match of the sequence of the sum of the frequency to the cumulative sum of the frequency.

enter image description here

P.b
  • 8,293
  • 2
  • 10
  • 25