Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
I have been trying to create the filter to pull the previous month data only from the date field formatted like this : 2024-09-02 02:41:11.787 , but i am not winning i tried multiple solutions and getting errors, kindly assist on which logic/formula should i use.
Thanks in Advance.
Your date field is actually a time-stamp.
I would suggest to build a calendar table, based only on the dates (not the times) in this field.
You can make a 'real' date field by using
Date(Floor([TimestampfField])) as Date
Then create a calendar table that references it. I personally like this one:
https://qlikviewcookbook.com/2015/05/better-calendar-scripts/
After you can use a Month or MonthNum or even a YYYYMM to reference the current and previous month.
An alternative method, without using a Calendar table would be to add a field like this:
if(MonthName([Timestamp]) = Monthname(AddMonths(Today(), -1)), 1, 0) as PreviousMonth.
All of the Timestamps in the previous month will have a 1 in this field.
Hi @Thabang231
I agree with @madelonjansen and @David_Friend.
Besides if you need more info read those:
There are also existing topics on community which answer the same question:
Bottom line is that you need to understand:
cheers
Your date field is actually a time-stamp.
I would suggest to build a calendar table, based only on the dates (not the times) in this field.
You can make a 'real' date field by using
Date(Floor([TimestampfField])) as Date
Then create a calendar table that references it. I personally like this one:
https://qlikviewcookbook.com/2015/05/better-calendar-scripts/
After you can use a Month or MonthNum or even a YYYYMM to reference the current and previous month.
An alternative method, without using a Calendar table would be to add a field like this:
if(MonthName([Timestamp]) = Monthname(AddMonths(Today(), -1)), 1, 0) as PreviousMonth.
All of the Timestamps in the previous month will have a 1 in this field.
@Thabang231 if the suggestion from @madelonjansen helped you please click on 'Accept as Solution'
Hi @Thabang231
I agree with @madelonjansen and @David_Friend.
Besides if you need more info read those:
There are also existing topics on community which answer the same question:
Bottom line is that you need to understand:
cheers