# QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Contributor 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

Tags (1)
1 Solution

Accepted Solutions
Contributor III

## Re: Help with a date calculation

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

## Re: Help with a date calculation

Try to use same in expression as set analysis..

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Contributor III

## Re: Help with a date calculation

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

Esteemed Contributor III

## Re: Help with a date calculation

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)

Highlighted

## Re: Help with a date calculation

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)

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Contributor III

## Re: Help with a date calculation

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

Contributor III

## Re: Help with a date calculation

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

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

## Re: Help with a date calculation

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"

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

## Re: Help with a date calculation

Script

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Contributor III

## Re: Help with a date calculation

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