Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
manu1512
Creator
Creator

sales for last 4 weeks

Hi ,

I want to calculate sales for last weeks excluding last 28 days excluding saturday sunday.

Can any one help me

Regards

Manu

3 Replies
YoussefBelloum
Champion
Champion

Hi,

can you elaborate more with an example ?

where do you want to use this expression ?

do you want to use a set analysis for this ?

can you share a screenshot of your data model ?

Anil_Babu_Samineni

The simplest way can

WeekDay(DateField) as WeekDay,

Week(DateField) as Week

And then Set analysis should

Sum({<Week = {">=$(=Max(Week)-4)<=$(=Max(Week))"}, WeekDay -= {'Sat','Sun'}>} Sales)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
ben_pugh
Creator
Creator

This will give you the last 28 days:

sum({<Date={"$(=max(Date)-28)"}>} Sales)


Then you need to find a way to exclude weekends. This is anything where the WeekDay function returns <5 (this runs from 0=Monday to 6= Sunday)


so you could add this to your set analysis: WeekDay(YourDateField)*1<5

(the *1 is to force the result to be numeric)