Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Fahad
Contributor II
Contributor II

Filter qvd by previous month

Hey All,

 

I need to filter my data In the Load Editor to only get me the previous months Data, It's for an Nprinting Report and I would really appreciate your help.

1 Solution

Accepted Solutions
rubenmarin

Hi, in script you only need to add that row as it is in the tabe where data with dates is loaded, just change "DateField" by your current field storing the date.

LOAD
  DateField,
  OtherFields,
  If(MonthName(DateField)=MonthName(AddMonths(Today(),-1)), 1, 0) as isLastMonth // this is the new row to add in script.
From/resident...

In NPrinting go to connections and reload metadata to have the new isLastMonth field avaible.

Go to filters section and create a new filter, just select the connection, the field isLastMonth and select numeric value 1.

The apply this filter to the report in reports->filters .

View solution in original post

7 Replies
rubenmarin

Hi, when loading data you can create a flag like:

If(MonthName(DateField)=MonthName(AddMonths(Today(),-1)), 1, 0) as isLastMonth

Then you only need to apply the filter in NPrinting so isLastMonth=1.

Or if you want to filter data directly while loading the app just apply this logic on the where caluse when loading data.

Fahad
Contributor II
Contributor II
Author

Hey Rubenmarin,

Thanks for the help Am Kind of New to both Nprinting and Qlik sense In general  If it's Possible of you to show the Script of How I can Apply the filter In the Load Editor, And dose the filed have to be month or it's ok to be date or date time.

 

Thanks and I appreciate your Support

rubenmarin

Hi, in script you only need to add that row as it is in the tabe where data with dates is loaded, just change "DateField" by your current field storing the date.

LOAD
  DateField,
  OtherFields,
  If(MonthName(DateField)=MonthName(AddMonths(Today(),-1)), 1, 0) as isLastMonth // this is the new row to add in script.
From/resident...

In NPrinting go to connections and reload metadata to have the new isLastMonth field avaible.

Go to filters section and create a new filter, just select the connection, the field isLastMonth and select numeric value 1.

The apply this filter to the report in reports->filters .

Fahad
Contributor II
Contributor II
Author

Hey Rubenmarin,

 

I meant for the where Statement  after the from but It works now thanks 👍.


where MonthName(DateField)= MonthName(AddMonths(Today(),-1))

Fahad
Contributor II
Contributor II
Author

@rubenmarin Hey,

 

Thanks for the previous answer,

If you can Help me filter the same Info from Before for a previous week filter,

 

similar to this but for Previous week:

where MonthName(DateField)= MonthName(AddMonths(Today(),-1))

 

Thanks And I appreciate your support

rubenmarin

Hi, It could be something like:

where DateField>=WeekStart(Today()-7) and DateField<=WeekEnd(Today()-7)

Here is when flags makes sense, because you can have one document with all data needed for your reports and then in nprinting apply the filter for last month or last week as need: for each report or even each object inside the same report.

 

Fahad
Contributor II
Contributor II
Author

Thank you Very much for your Support