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

Last 3 days and Month to date

Hi All,

I have the following expressions:

Current Month to date

= sum({$<Month={"$(=Date(Max(Month),'MMM-YY'))"}>}[Sales])

Previous Month to date

= sum({$<Month={"$(=Date(addmonths(Max(Month),-1),'MMM-YY'))"}>}([Sales])

these 2 works fine but i want to add another field that could see less 3 days Current Month to date and less 3 days Previous Month to date. e.g. i select July 1 to 5 but it would only select July 3 to 5 only on the next two expressions.

My Script below:

LOAD

Day (Date) as DayDate,

Month( Date) as MonthDate,

Year (Date) as YearDate,

Date(Date,'MM-DD-YYYY') as Date,

Date(Date,'MMM-YY') as Month,

Sales,

Customers

;

SQL SELECT * FROM dbo.customers;

Thanks

7 Replies
sunny_talwar

What would you want to see when you select Jun 5th to Jun 15th? I am not completely sure I understand what your goal is?

Anonymous
Not applicable
Author

Hi Sunny,

For example i select July 1 to 5 ( month to date) i can see these transaction details but also want to see together with the last 3 days July 3 to 5 (month to date).

Anonymous
Not applicable
Author

the user wants to see last 3 days vs month to date transactions in their report.

Anil_Babu_Samineni

Perhaps this?

Current MTD

= sum({$<DayDate={">=$(=Max(DayDate-2))<=$(=Max(DayDate))"}, Month={"$(=Date(addmonths(Max(Month),-1),'MMM-YY'))"}>}[Sales])

Previous MTD

= sum({$<Month={"$(=Date(addmonths(Max(Month),-1),'MMM-YY'))"}, DayDate={">=$(=Max(DayDate-2))<=$(=Max(DayDate))"}>}([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
Anonymous
Not applicable
Author

Capture.PNG

Here is a visual guide

Anonymous
Not applicable
Author

Hi Anil,

it didnt work.

sunny_talwar

So, the user will never select Jun 5th to Jun 15th? or Jun 1st to Jun 15th? You are repeating the same example over and over... I am looking for understanding the requirement based on multiple different selections