Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

birkirbjorns
New Contributor III

Last day of week - Set analysis

Hi,

I have a set of inventory data. I would like to create a chart or table that shows inventory status on the last day of the week. So If I would choice weeks from nr.1 to nr.10 it would sum the inventoryvalue for the last day of all the weeks. Is this possible with set analysis?

The data looks something like this.

InvTrans:

LOAD * INLINE [

Date, Product,Store,Qty,EntryType

2017-02-28, 1,1,100,0

2017-03-01, 1,1,-10,1

2017-02-28,2,2,100,0

2017-03-03, 2,2,-10,1

2017-03-02, 1,1,100,2

2017-03-02,2,2,500,2

2017-03-04,1,2,-50,1

];

Any hints greatly appreciated.

Regards

Birkir

1 Solution

Accepted Solutions
MVP
MVP

Re: Last day of week - Set analysis

Maybe like

=Sum({<Date = {"=WeekDay(Date)=6"}>} Qty)

But it would be good to create a flag in your script that flags dates that fulfill your requirement:

LOAD

     Date,

     If(WeekDay(Date) =6,1,0) as LastWeekDayFlag,

     ...

then

=Sum({<LastWeekDayFlag = {1} >} Qty)

3 Replies
MVP
MVP

Re: Last day of week - Set analysis

Maybe like

=Sum({<Date = {"=WeekDay(Date)=6"}>} Qty)

But it would be good to create a flag in your script that flags dates that fulfill your requirement:

LOAD

     Date,

     If(WeekDay(Date) =6,1,0) as LastWeekDayFlag,

     ...

then

=Sum({<LastWeekDayFlag = {1} >} Qty)

birkirbjorns
New Contributor III

Re: Last day of week - Set analysis

Hi Stefan,

Thank you for the help. This works like a charm, I think I will use the LastWeekDayFlag.  Would this be a good idea or practice to put it into a mastercalendar load?

Regards

Birkir

MVP
MVP

Re: Last day of week - Set analysis

Yes, that's what I would do.