Qlik Community

Qlik NPrinting Discussions

Discussion Board for collaboration on Qlik NPrinting.

ashishpalkar
Contributor III

find today()-1 except saturday and sunday

Hi There

I am looking for filter like following

find today()-1 except saturday and sunday.

i.e If Today()-1 is Sunday, then filter should give Friday's date.

Thanks in advance,

4 Replies
arvind1494
Valued Contributor

Re: find today()-1 except saturday and sunday

Do you want this in filter pane

ashishpalkar
Contributor III

Re: find today()-1 except saturday and sunday

Yes, in filters section of NPrinting Report.

Employee
Employee

Re: find today()-1 except saturday and sunday

Hi,

The solution is to create a calculated field in the connected Qlik Sense app or QlikView document. The field will be true if the condition you need is met. It is a date based condition so you need to run a data reload at least daily.

After you did the document update remember to save it and regenerate the Qlik NPrinting connection cache in order to make the new field visible in the Qlik NPrinting Designer.

Best Regards,

Ruggero

---------------------------------------------

When applicable please mark the appropriate replies as CORRECT https://community.qlik.com/docs/DOC-14806. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads as HELPFUL if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads as HELPFUL if you feel additional info is useful to others.



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.

Re: find today()-1 except saturday and sunday

This is how you possibly can handle it. Note that my calendar is only Autogenerated sample so you will have to adjust code to apply flag in your calendar

In NPrinting Filter would be then

  • Field                        = Flag
  • NumericValue is      = 1

Sample Code:

SET ThousandSep=',';

SET DecimalSep='.';

SET MoneyThousandSep=',';

SET MoneyDecimalSep='.';

SET MoneyFormat='$#,##0.00;($#,##0.00)';

SET TimeFormat='h:mm:ss TT';

SET DateFormat='D/MM/YYYY';

SET TimestampFormat='D/MM/YYYY h:mm:ss[.fff] TT';

SET FirstWeekDay=6;

SET BrokenWeeks=1;

SET ReferenceDay=0;

SET FirstMonthOfYear=1;

SET CollationLocale='en-US';

SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';

SET LongMonthNames='January;February;March;April;May;June;July;August;September;October;November;December';


// Notice Day Names abbreviations in your Qlik variables

SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

SET LongDayNames='Monday;Tuesday;Wednesday;Thursday;Friday;Saturday;Sunday';


// Check Yesterday date

Let vYesterday = Date(Today()-1);

Let vYesterdayNum = Num(Today()-1);

Trace Yesterdayis: $(vYesterday);

// Check Yesterday's day name

Let vYesterdayDayName = Text(WeekDay($(vYesterdayNum)));

Trace Yesterdays day name is: $(vYesterdayDayName);

// Check what date needs to be created as filter // Here i am assuming you for Sat and Sun filter will return Friday

Switch vYesterdayDayName


Case 'Sat'

Let vFilterDate = num(Today()-2);

Case 'Sun'

Let vFilterDate = num(Today()-3);

Default

Let vFilterDate = num(Today()-1);

End Switch

Trace Filter Date is $(vFilterDate);


// In your calendar flag date which you want to filter


temp_Calendar:

LOAD

Date(Today()-20+RowNo()) as yourDateField

AutoGenerate

25

;

Calendar:

LOAD

Date(yourDateField) as Date,

Month(yourDateField) as Month,

Year(yourDateField) as Year,

If(yourDateField = $(vFilterDate),1,0) as Flag  // create a flag and use it as a filter in NPrinting

Resident

temp_Calendar

;


DROP Table temp_Calendar;

// End


Cheers,

Lech

---------------------------------------------

When applicable please mark the appropriate replies as CORRECT https://community.qlik.com/docs/DOC-14806. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads as HELPFUL if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads as HELPFUL if you feel additional info is useful to others.

cheers Lech, 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 to the problem.