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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Current Week-4

Hi

I need a week,which will be current week minus 4 week.How to achieve this in UI.

Ex:My Current Week: 2013 W05

Expected Week is:(Current week-4) ie) 2013W01.

How to achieve this.Please help me.

Thanks,

Gowthami

11 Replies
MK_QSL
MVP
MVP

=Max(Week)-4

You can use as

SUM({$<Week = {"$(=Max(Week))"}>}Sales)  // Max Week from selected weeks

SUM({$<Week = {"$(=Max(Week)-4)"}>}Sales)  // Max Week - 4 from selected weeks

Not applicable
Author

Hi Gowthami

Why can't you just subtract 4*7 from your date?

Lukasz

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

If you calculate your weeks from a date field I suggest you create it as a dual field:

load

    FieldA, FieldB, ...etc ,

    MyDate,

    dual( Year(MyDate) & 'W' & num(week(MyDate),'00') , weekstart(MyDate)) as MyWeek

From ...etc;

This way the MyWeek values will really still be dates (just shown like 2013W05) and you can subtract a number of days from it:

Expected Week = Current Week - 28

Current Week: max(MyWeek)

Expected Week: max(MyWeek)-28

Perhaps you need to use the weekyear function instead of the year function. Look the weekyear function up in the help file to understand why.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi ,

Thanks for your reply.

I have an inputbox, with two fields."Week1" and "Week2"

By default my

"Week 2" should be my Current week.

  "Week1" should be  current week minus 4

Week field is like this:

2013 W05

2013W04

2013W03

Max(week-4) is not working...

Thanks

Gowthami

ThornOfCrowns
Specialist II
Specialist II

Make sure you have your brackets right, Max(Week)-4 =/= Max(Week-4)

giakoum
Partner - Master II
Partner - Master II

Max(Week)-4 will never work this way. Imagine week being 2014W01. What would be Max(Week)-4? Go with Gysbert's suggestion (again )...

Not applicable
Author

Hi,

Thanks for you reply.I don't have any date fileld in my QVD.

Thanks,

Gowthami


giakoum
Partner - Master II
Partner - Master II

then you maybe should create one using the week information. This will be helpful further on as well in your development.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You could ask the person that created that qvd to put a date field in. That week field was created somewhere and most likely from a date field. Or ask him/her to create a dual field like I mentioned. Or ask him/her to at least add a numeric sequential week field so you have a field that can used in calculations to derive an earlier week.


talk is cheap, supply exceeds demand