Skip to main content
Solved

I am trying to create a component filter for "the running past 24 months". - I can get a "since 2022" to work, but I can't get a floating filter, like "for the past two years" to work.Can you help me with the general syntax?Thank you.

  • April 23, 2024
  • 4 replies
  • 5 views

karl.guent
Level 6
Forum|alt.badge.img
I am trying to create a component filter for "the running past 24 months". - I can get a "since 2022" to work, but I can't get a floating filter, like "for the past two years" to work. Can you help me with the general syntax? Thank you.

Best answer by stephanie.parra

Hi,

for the past 24 months simply use ADD_MONTHS(TODAY(),-24) in the comparison, i.e.

FILTER Table.Date >= ADD_MONTHS(TODAY(),-24)

BR

Stephanie

4 replies

Sverre Klein
Level 10
Forum|alt.badge.img+14
  • Level 10
  • 204 replies
  • April 24, 2024

Hi @karl.guent,

 

Very good question, I never tried this but I got something working.

 

FILTER YEAR ("ACTIVITIES_TABLE_PO"."EVENT_TIME") => (YEAR(TODAY()) - 2);

 

Let me know if this works on your end. Please validate the results 😁

 

EDIT: I think it should be => rather than >, I changed this.

 

Kind regards,

Sverre Klein


  • Level 6
  • 11 replies
  • Answer
  • April 24, 2024

Hi,

for the past 24 months simply use ADD_MONTHS(TODAY(),-24) in the comparison, i.e.

FILTER Table.Date >= ADD_MONTHS(TODAY(),-24)

BR

Stephanie


karl.guent
Level 6
Forum|alt.badge.img
  • Author
  • Level 6
  • 20 replies
  • April 24, 2024

Wow! These are both awesome!

  • Stephanie ... The "TODAY -24 is truly elegant.
  • Sverre ... the From => To approach is the way I was also thinking.

Sverre Klein
Level 10
Forum|alt.badge.img+14
  • Level 10
  • 204 replies
  • April 24, 2024

Hi,

for the past 24 months simply use ADD_MONTHS(TODAY(),-24) in the comparison, i.e.

FILTER Table.Date >= ADD_MONTHS(TODAY(),-24)

BR

Stephanie

Very nice, thanks Stephanie! 😊