cancel
Showing results for
Did you mean:
Creator III

## Help with a date calculation

Hi all

I would like some help with this please:

I am in Chart properties - It is a line chart - works beautifully when I have:the dimension

=date(AppointmentDate, 'www dd/MM/yyyy')

But

as part of a dashboard I would like to amek the same chart just show a week of data, starting 7 days before today.

The expression below in the Enable conditional box does not work.

date(AppointmentDate) >= date(today()-3)

Thank you

Jo Tedesco

1 Solution

Accepted Solutions
Creator III
Author

Thank you both

I have used this formula:

=if(AppointmentDate>= date(weekstart(today()-3)),date(AppointmentDate))

I placed it in the

chart properties

Dimensions

Edit - Used Dimensions.

I would have liked to use it in the set analysis but too complicated - I might try later.

Thank you again

Jo

12 Replies

Try to use same in expression as set analysis..

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Creator III
Author

How do I write it in the expression using set analysis?  I am unsure how to use quotes etc.

date(AppointmentDate) >= date(weekstart(today()))

sum({< AppointmentStatus = {'Completed'}>}sales

Champion III

Where you want to include this date? What is your actual date format of your AppointmentDate field.

May be like

= Sum(({< AppointmentStatus = {'Completed'} , AppointmentDate = {">= \$(Date(WeekStart(Today() -7)))"} >} sales)

Left hand part you can't use calculations. I would prefer in script like

Date(AppointmentDate) as AppointmentDate // Or may be name changed

Then, Set analysis should be

sum({< AppointmentStatus = {'Completed'}, AppointmentDate = {"=AppointmentDate >= date(weekstart(today()))"}>} sales)

To make more clear, You can do like below as well

If(date(AppointmentDate) >= date(weekstart(today())), 1,0) as Flag

Then analysis should be

sum({< AppointmentStatus = {'Completed'}, Flag = {1}>}sales)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Creator III
Author

Thank you both

I have used this formula:

=if(AppointmentDate>= date(weekstart(today()-3)),date(AppointmentDate))

I placed it in the

chart properties

Dimensions

Edit - Used Dimensions.

I would have liked to use it in the set analysis but too complicated - I might try later.

Thank you again

Jo

Creator III
Author

To make more clear, You can do like below as well

If(date(AppointmentDate) >= date(weekstart(today())), 1,0) as Flag

In fact, I don't like to use calculated dimensions until unless needed and it kills the performance. If you read optimize document from community there you will will get front end optimize tips and first initiate point is the same "Don't use Calculated dimensions"

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

Script

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Creator III
Author

Sorry Anil – I am not sure what has happened – I meant to mark your answer as correct, but I hit the wrong button! Too much multi tasking. Will you be able to change it? Or give me instructions how I can change it?

Jo

Community Browser