Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

akpofureenughwu
Contributor II

Previous Date Calculation

Hello everyone,

I got this table where I need to compare current date (max date = 20/02/2018) and previous date ( 19/02/2018)

I tried using

Sum({<Date= {"$(=Max(Date))"}>} [Partner Closing Stock]) -------- Correct

Sum({<Date= {"$(=Max(Date) -1)"}>} [Partner Closing Stock])  ------- not giving me the right answer



Can you help me?


Thank you

9 Replies
ogautier62
Valued Contributor II

Re: Previous Date Calculation

HI

Write max(total date

Otherwise max is on your dimension

Regards

eduardo_dimperi
Valued Contributor II

Re: Previous Date Calculation

Try this:

Sum({<Date={'$(Max(Date)-1)'}>}[Partner Closing Stock])


giovanneb
Contributor II

Re: Previous Date Calculation

Hello, would this

Sum({<Date= {"$(=date(Max(Date)-1))"}>} [Partner Closing Stock])

akpofureenughwu
Contributor II

Re: Previous Date Calculation

Hello giovanneb‌     @dlmperio

Thank you for your attempts however your suggested expressions are still not giving me the values of the previous date.

stalwar1  londosoanderson

Can you give your feeds on this>?

Regards

giovanneb
Contributor II

Re: Previous Date Calculation

Hi, please append the qvf for me to parse

akpofureenughwu
Contributor II

Re: Previous Date Calculation

Have a look

Thank you

MVP
MVP

Re: Previous Date Calculation

It seems you only have monthstart dates 2/1/2017 is feb 1st and 1/1/2017 is jan 1st. If that is true, then try this

Sum({<Date= {"$(=Date(MonthStart(Max(Date), -1)))"}>} [GAS PRODUCED])

akpofureenughwu
Contributor II

Re: Previous Date Calculation

Hello Sunny

stalwar1

Thank you for reaching out

The script you proposed still didn't give me the desired result.

Attached is an excel extract from the SQL Db.  Kindly inspect the tables and let see how it goes

thanks

MVP
MVP

Re: Previous Date Calculation

Based on this data, I would think that this should work

Sum({<Date= {"$(=Date(Max(Date)-1, 'YYYY/MM/DD'))"}, Month, Year, Day>} [GAS PRODUCED])