Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Custom Filter using DateTime no longer working?

Crispy131
8 - Asteroid

I have a workflow that feeds into a dashboard I completed last month and it was working fine. The workflow runs every month. It ran this month (January) and the dashboard was blank. When I check the workflow this custom filter I have is no longer working? The True is blank (returns 0 records).

 

The custom filter is below. Basically the formula says if the month of today's date is January then return November of last year's data. If it's February then return December of last year, otherwise give me the data from the month that is two months ago from today's month. 

 

The filter is this:

 

IF DateTimeMonth(DateTimeToday()) = 1 THEN
(DateTimeYear([SalesDate]) = DateTimeYear(DateTimeToday())-1)
AND
(DateTimeMonth([SalesDate]) = DateTimeMonth(DateTimeToday())-2)


ELSEIF DateTimeMonth(DateTimeToday()) = 2 THEN
(DateTimeYear([SalesDate]) = DateTimeYear(DateTimeToday())-1)
AND
(DateTimeMonth([SalesDate]) = DateTimeMonth(DateTimeToday())-2)


ELSE
(DateTimeYear([SalesDate]) = DateTimeYear(DateTimeToday()))
AND
(DateTimeMonth([SalesDate]) = DateTimeMonth(DateTimeToday())-2)
ENDIF

 

 

I can't see what's going wrong. Any help is much appreciated!

2 REPLIES 2
DataNath
17 - Castor
17 - Castor

Hey @Crispy131, for this part of your statement:

 

(DateTimeMonth([SalesDate]) = DateTimeMonth(DateTimeToday())-2)

 

In January/February, DateTimeMonth - 2 will return a result of -1 and 0 respectively as you’re taking 2 away from the month number (1 and 2). Therefore you should change this part to DateTimeMonth([SalesDate]) = 11 for January, and 

DateTimeMonth([SalesDate]) = 12 for February, leaving out the subtraction of DateTimeToday’s month.

Crispy131
8 - Asteroid

You legend! Thank you so much such an easy fix I was overthinking it. Thank you!

Labels
Top Solution Authors