How to write date period calculation in QS?

Hi team could you please help me to write date period clac using parameter

if date param=’year’ then year(today)

else if date param=’ previous year’ then datetrunc(‘year’,today())-1

elseif date param=’quarter’ then datetrunc(‘quarter’,today())

elseif date param=’previous quarter’ then datetrunc(‘quarter’, dateadd(‘day’,-1,datetrunc(‘quartrer’,today()))

elseif ‘none’

above calc is working in QS? if not please help me to write correct calc.

Thanks in advanced

Regards,

Chaitanyakumar N

Consider using the now() function in Quick Sight Now - Amazon QuickSight

You can use a combination of other date functions Functions by category - Amazon QuickSight to extract the day/month/year value from now’s value.

Hi @Cnagabhairava

It’s been a while since we last heard from you. If you have any further questions, please let us know how we can assist you.

If we don’t hear back within the next 3 business days, we’ll proceed with close/archive this topic.

Thank you!

yes please Xclipse, I need solution for my question

Hi @Cnagabhairava

You can use the now(), addDateTime(), and extract() functions to extract the Year, Quarter, and Previous Year and Quarter.

Example:

Year - extract('YYYY', now())

Previous Year - extract('YYYY',addDateTime(-1, 'YYYY',  now()))

Quarter - extract('Q', now())

Previous Quarter - extract('Q',addDateTime(-1, 'Q',  now()))

Thank you for answering and support