Need help in replicating this calculated field from tableau to quicksight

CASE [Creation YTD Switch]
WHEN True THEN
(IF DATEPART(‘month’,[Start Date 2])> DATEPART(‘month’,[Start Date 1])
THEN DATEADD(‘month’,DATEPART(‘month’,TODAY())-DATEPART(‘month’,[Start Date 2]),[Fictional Start Date 1])

ELSE DATE([Start Year 1]+‘-’+DATENAME(‘month’,TODAY())+‘-’+DATENAME(‘day’,TODAY()))
END)
WHEN FALSE THEN DATEADD(‘month’,[Parameters].[Creation Period Length],[Start Date 1])
END

1 Like

Hello @Hunny, I am unfamiliar with tableau calculations. What exactly are you wanting to accomplish with the calculated field? It looks like you will be using an ifelse statement, with some other date related calculations like addDateTime, extract, and truncDate.

With some more information about the expected output, I should be able to guide you further. Thank you!

1 Like

Hi @Hunny -

You just need to map some of the functions to their QuickSight parities that @DylanM provided.

Try something like this.

ifelse(
  ${booleanParameter} = 1,
  ifelse(
    extract('MM', date) > extract('MM', date),
    addDateTime(
      extract('MM', now()) - extract('MM', date),
      'MM',
      date
    ),
    parseDate(
      concat(
        toString(extract('YYYY', date)), '-',
        toString(extract('MM', now())), '-',
        toString(extract('DD', now())), ' '
      ),
      'yyyy-MM-dd'
    )
  ),
  addDateTime(${periodLength}, 'MM', date)
)
2 Likes

Hello @Hunny, since we have not heard back from you, I will mark @robdhondt’s response as the solution. Please let us know if you have any further questions on this topic and we can guide you further. Thank you!

2 Likes

It doesn’t work, still getting errors