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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculation of amount of weeks?

Hello,

how can I count amount of weeks from now to date I get from DATE field. DATE field contains values like this: 20170922, 20170513,.... I need to calculate how many weeks it is always from present day minus dates in that field DATE. So present day - 20170922=amount of weeks. Thx in advance!

7 Replies
PrashantSangle

use week()

try like

week(today())- week(week(date#(YourdateField,'YYYYMMDD')))

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Anonymous
Not applicable
Author

Thx for your reply but unfortunately it returns wrong values.

For example for value 20170923 it´s 41weeks.

For value 20170818 it´s 42 weeks.

For value 20161222 it´s 39 weeks.

its_anandrjs
Champion III
Champion III

I assume you have correct and pure date filed why not try this way.

Week(DateField) as WeekField

And on UI part count values this way

=Count( Distinct WeekField)

PrashantSangle

can you tell us logic behind it???

How did you get this.

For Value 20170923 it´s 41weeks.

For value 20170818 it´s 42 weeks.

For value 20161222 it´s 39 weeks

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Anonymous
Not applicable
Author

I´ve used your formula: week(today())- week(week(date#(DATE,'YYYYMMDD')))

In one column I have dates from DATE field and in the second one are results like you see above.

Anonymous
Not applicable
Author

Thx for your help but in table box object I cannot use expression or calculated dimension.

MarcoWedel

Hi,

maybe one solution could be:

QlikCommunity_Thread_282254_Pic1.JPG

table1:

LOAD *,

    (WeekStart(Today())-WeekStart(DATE))/7 as Weeks;

LOAD Date#(DATE,'YYYYMMDD') as DATE  

Inline [

    DATE

    20161222

    20170513

    20170818

    20170922

    20170923

];

hope this helps

regards

Marco