0

Create a range of consecutive values for the X-axis

I was looking for a way to create a range of consecutive values, to serve as an X-axis.

 

Solved it like this in the end but it seems to be a difficult workaround:

 

sort(
map(
(
daterange(
DATE_ADD(today(), "1", -1),
today()
)
),
"date_array",
COUNT_DAYS($date_array, today())
),
"ascnumeric"
)

 

any simpler solutions?

2 comments

  • 0
    Avatar
    Janice Janczyn

    Hi Bart,

    To build a date range, you can simply use the DATERANGE function: DATERANGE( DATE_ADD( TODAY(), year, -1) .

    To build a list of consecutive numbers, use CUMULATIVE( REPEAT( 1, 366) ) which will return 366 values, from 1, 2, 3...365, 366. 

    To reverse the order of either of these, wrap REVERSE around the formula, that is, REVERSE( CUMULATIVE( REPEAT( 1, 366) ) ), which will return 366 values, from 366, 365, 364...3, 2, 1.

    I hope this helps!

    Janice

  • 0
    Avatar
    Bart Jonk

    Thanks Janice,

    I already thought there should a simpler way, but just couldn't find it. 

    At least now it's documented for people with a similar question.

     

    cheers,

    Bart.

     

Please sign in to leave a comment.