Forum Discussion

NPC's avatar
NPC
Helper I
4 years ago
Solved

Moving Target

Hello,

I need to create a taget that increases automatically by 200 each week on Thursdays. The target will be diplayed on a card. The code below works but I want to avoid hard coding dates because then I'll have to manually change the date at the beggining on next year.
 
Thanks for your help. Below is what I came up with.
 
Moving Target =
 
VAR WK45 = 200*13
VAR WK46 = 200*14
VAR WK47 = 200*15
VAR WK48 = 200*16
VAR WK49 = 200*17
VAR WK50 = 200*18
VAR WK51 = 200*19

 

return
IF(TODAY()>=DATE(2021,11,11) && TODAY()<=DATE(2021,11,17), WK45,
IF(TODAY()>=DATE(2021,11,18) && TODAY()<=DATE(2021,11,24), WK46,
IF(TODAY()>=DATE(2021,11,25) && TODAY()<=DATE(2021,12,01), WK47,
IF(TODAY()>=DATE(2021,12,02) && TODAY()<=DATE(2021,12,08), WK48,
IF(TODAY()>=DATE(2021,12,09) && TODAY()<=DATE(2021,12,15), WK49,
IF(TODAY()>=DATE(2021,12,16) && TODAY()<=DATE(2021,12,22), WK50,
IF(TODAY()>=DATE(2021,12,23) && TODAY()<=DATE(2021,12,31), WK51)))))))
  • Try something like this:

    Target = 200 * ( 13 + ROUNDDOWN ( ( TODAY() - DATE ( 2021, 11, 11 ) ) / 7, 0 ) )

    This adds the number of weeks beyond the initial 11/11/2021 to 13 before multiplying by 200.

2 Replies

  • Try something like this:

    Target = 200 * ( 13 + ROUNDDOWN ( ( TODAY() - DATE ( 2021, 11, 11 ) ) / 7, 0 ) )

    This adds the number of weeks beyond the initial 11/11/2021 to 13 before multiplying by 200.