Start Free Trial

Alteryx Designer Desktop Discussions

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

Get value based on current week

keeprollin
7 - Meteor

I have a column which contains the date when a product is being bought. I want to create a new column which would give me a yes or a no if a user buys a new product (starting date) in the current week. To simplify my statement - How can I dynamically get a Yes if the starting date falls in the current week? The current week should start on Monday and end on Sunday.  I'm providing a sample dataset below.

 

Starting dateCurrent Week
12/31/2021No
10/6/2021No
12/17/2021No
11/3/2021No
1/21/2022No
1/20/2022No
1/30/2022No
1/31/2022Yes
2/1/2022Yes
2/2/2022Yes
2/3/2022Yes
2/4/2022Yes
2/5/2022Yes
2/6/2022Yes

 

In this case, I have used the following formula:  

 

if DateTimeDiff([Starting date],DateTimeToday(),'days') >= -2

and DateTimeDiff([Starting date],DateTimeToday(),'days') <=4

THEN "Yes"

ELSE

"No"

ENDIF

 

However, the issue is that let's assume that the starting date has its values as '2/5/2022' and '2/6/2022' and today's date is '2/7/2022', then also the current week column will give Yes, even though 2/5/2022 would be last week. Can someone please help me solve this problem statement? 

 

2 REPLIES 2
AngelosPachis
16 - Nebula

Hi @keeprollin ,

 

What you can try instead is to get the week number from your dates in the [Starting date] field. To do that you will have to use a Datetime function that returns the week number when the first day of the week is number 

 

DateTimeFormat([Date formatted],"%W")

 

Then you can do the same with today's date and compare the two numbers with an if statement, as shown below:

AngelosPachis_0-1643834780615.png

 

Hope that helps,

Angelos

binu_acs
21 - Polaris

@keeprollin similar to @AngelosPachis approach

 

IIF(DateTimeFormat(DateTimeParse([Starting date],'%m/%d/%Y'),"%W") == DateTimeFormat(DateTimeNow(),"%W"), 'Yes','No')

binuacs_0-1643837979141.png

 

Labels
Top Solution Authors