In case you missed the announcement: Alteryx One is here, and so is the Spring Release! Learn more about these new and exciting releases here!
Free Trial

Alteryx Designer Desktop Discussions

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

FORMULA TOOL - if function

Basma_alrubaish
6 - Meteoroid

Hi everyone ,

 

 

im trying to add an if function in formula for a semi annual report (jan-june, june-dec) of each year 

 

if [input] date is in (anyday-06-(year) then result in 01-01-(same year)

and if the [input] date is in (anyday-12-(year) then result in 01-06-(same year)

 

what should my formula look like?

4 REPLIES 4
dwstada
11 - Bolide

@Basma_alrubaish your request is kinda confusing, but here is a formula for how I understood it

 

if DateTimeMonth([input]) <= 6
then "01-01-"+ToString(DateTimeYear([input]))
else "01-07-"+ToString(DateTimeYear([input]))
endif

 

this turns all dates from Jan-June into 01-01-2024 and July-Dec into 01-07-2024. Not sure why your semi annual report would use June twice, so I changed that to July.

 

Maybe this helps you already, otherwise please clarify what you want to do :)

 

ChrisTX
16 - Nebula
16 - Nebula

Try formula:

 

IF DateTimeMonth(DateTimeNow()) <= 6
THEN ToString(DateTimeYear(DateTimeNow()),0) + "-01-01"
ELSE ToString(DateTimeYear(DateTimeNow()),0) + "-06-01"
ENDIF

 

Output data type: Date

 

Check out the DateTime functions:   https://help.alteryx.com/current/en/designer/functions/datetime-functions.html

 

Screenshot 2024-08-05 062228.png

 

Chris

Basma_alrubaish
6 - Meteoroid

@ChrisTX thank you so much 

 

but this would be calculating based on todays value date right? i need something that takes the value date in my data like this for example 

 

inputoutput
12/31/20246/1/2024
6/30/20241/1/2024
12/31/20256/1/2025
ChrisTX
16 - Nebula
16 - Nebula

If the field [input] is data type Date or DateTime, just replace "DateTimeNow()" with "[Input]"    without the quotation marks

 

Labels
Top Solution Authors