10 Replies Latest reply: Sep 26, 2018 12:02 PM by Andrea Gigliotti

# How to filter data on the previous week?

Hi everyone !

I solicit your help because it's been over a week that I use Qlik and I have a lot of trouble with the syntax of set analysis. I can not filter my data (which runs from August 2017 to today) weekly.

My goal is to show the sum of the numbers only from last week. Here is the last iteration of my work:

Sum ({\$ <semaine = {"= \$ (= week (weekstart (today (), -1, first_week_day = 0)))"}>} etat_ok)

"semaine" is a column containing the number of the week (0 -> 53)

Can you tell me what's wrong? Or maybe point me to a document explaining how set analysis works ? or both ?

• ###### Re: How to filter data on the previous week?

maybe this:

=Sum( {< semaine = {"\$(=week( weekstart(today()-7) ))"} >} etat_ok )

I hope it helps.

• ###### Re: How to filter data on the previous week?

i tried it but it gives me this :

PS: it's a KPI

• ###### Re: How to filter data on the previous week?

try to create a text box with this expression:

=week( weekstart(today()-7) ))

and check what you get.

• ###### Re: How to filter data on the previous week?

the good writing is this : Week(WeekStart(Today(), -1, 0)), here the definition of weekStart you'll understand the function

https://help.qlik.com/en-US/sense/June2017/Subsystems/Hub/Content/Scripting/DateAndTimeFunctions/weekstart.htm?l=en-UK?l…

The one you gave me return blank box.

But mine give me : 38 as the number of last week. that one is good.

The problem is when i add this thing to the sum. it doesn't do the filter at all.

See :

• ###### Re: How to filter data on the previous week?

actually I get 38 as result using the expression I gave you.

in the script I have:

SET FirstWeekDay=6;

• ###### Re: How to filter data on the previous week?

anyway the right syntax is:

semaine = {"\$(=Week(WeekStart(Today(), -1, 0)) ) "}

• ###### Re: How to filter data on the previous week?

oh tx, can you explain me what's the difference between my syntax and yours ?

• ###### Re: How to filter data on the previous week?

in your syntax there is an equal sign more,

semaine = {"=\$(=Week(WeekStart(Today(), -1, 0)) ) "}

remember to mark the correct answer if applicable, to help other community members.