Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Compare data from two dates

Hi,

I wish to compare forecasts from two different forecast versions,

I have a table which basically is design as such:

ForecastDateSalesDateForecast
2012-01-012012-03-01100
2012-01-012012-04-0180
2012-01-012012-05-0190
2012-02-012012-03-01100
2012-02-012012-04-01100
2012-02-012012-05-01100

I have created a variable called MaxForecastDate defined as Max(ForecastDate). In this case, it returns '2012-02-01', and is used to determine the latest forecast version.

I have then created a chart with dimension SalesDate and expression:

=SUM({<GSFDate={'2012-02-01'} >} Forecast)

This works as expected, but I would like that the chart is dynamically updated when a new ForecastDate is added. To compare forecasts from the two forecast dates, I am planning to use the function AddMonth(MaxForecastDate, -1) .

Any help would be very appreciated!

Best regards

Martin

Labels (1)
1 Solution

Accepted Solutions
jagan
Partner - Champion III
Partner - Champion III

Hi,

Create another variable with

=AddMonth(MaxForecastDate, -1)

and use this new variable in the expression as you did previously

Regards,

Jagan.

View solution in original post

6 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     You can try with this

=SUM({<GSFDate={'$(MaxForecastDate)'} >} Forecast)

Celambarasan

jagan
Partner - Champion III
Partner - Champion III

Hi,

Use this

=SUM({<GSFDate={'$(=(AddMonth(MaxForecastDate, -1)))'} >} Forecast)

Regards,

Jagan.

Not applicable
Author

Perfect, I was trying with " istead of '...

Now I am trying to subtract a month,

=SUM({<ForecastDate={'$(AddMonth(MaxForecastDate, -1)'} >} Forecast)

Not applicable
Author

Hi Jagan

This is not returning any data. I can use AddMonth(MaxForecastDate, -1) as an expression which correctly returns '2012-01-01', but not when used in the set analysis.

jagan
Partner - Champion III
Partner - Champion III

Hi,

Create another variable with

=AddMonth(MaxForecastDate, -1)

and use this new variable in the expression as you did previously

Regards,

Jagan.

Not applicable
Author

I found the reason for the behaviour. AddMonth('2012-02-01', -1) returned '01-01-2012', which confused the set analysis. By applying the Date() function by Date(AddMonth('2012-02-01', -1), 'yyyy-MM-dd')