Generate a list of consecutive numbers , between two numbers

Hello,

Is there an easy way to generate a list of all numbers between two numbers , by giving only the first and the last number , via usersettings?

In an app, the user should imput
Field 1 : 4
Field 2: 7
Result : (4,5,6,7) (list)

Thank you very much

Solved Solved
0 3 731
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Itโ€™s possible with a relatively small number of numbers within a limited range:

(
  TOP(
    list-of-possible-numbers,
    last-number
  )
  - TOP(
    list-of-possible-numbers,
    (first-number - 1)
  )
)

Using your example values:

(
  TOP(
    LIST(1, 2, 3, 4, 5, 6, 7, 8, 9),
    7
  )
  - TOP(
    LIST(1, 2, 3, 4, 5, 6, 7, 8, 9),
    (4 - 1)
  )
)

Note that list-of-possible-values must be in order and contain no duplicate values.

View solution in original post

3 REPLIES 3

Steve
Platinum 4
Platinum 4

Itโ€™s possible with a relatively small number of numbers within a limited range:

(
  TOP(
    list-of-possible-numbers,
    last-number
  )
  - TOP(
    list-of-possible-numbers,
    (first-number - 1)
  )
)

Using your example values:

(
  TOP(
    LIST(1, 2, 3, 4, 5, 6, 7, 8, 9),
    7
  )
  - TOP(
    LIST(1, 2, 3, 4, 5, 6, 7, 8, 9),
    (4 - 1)
  )
)

Note that list-of-possible-values must be in order and contain no duplicate values.

I tried a table with a column with numbers from 1 to 200 , and a conditional slice of that table based on first and last number , so I can extract as list the sliceโ€™s column.

I was hoping to dump this workaround , and your solution seems perfect.

Thank you very much !

Thatโ€™s a great approach for a larger list of numbers!

SORT(
  SELECT(
    All Numbers[Number],
    AND(
      ([Number] >= first-number),
      ([Number] <= last-number)
    )
  )
)
Top Labels in this Space