If you are unable to create a new account, please email support@bspsoftware.com

 

an expression to check if previous day is a weekend in Dimensional reporting

Started by cognos05, 31 Jan 2016 11:04:30 PM

Previous topic - Next topic

cognos05

Hi,

I have to check if previous day is a weekend in cognos if condition
# _add_days ($current_timestamp, -1 ) #

How should my if expression be to check for a week day or weekend.

Thanks,
Nithya

schrotty

Hi,

what will your do when your check is true or false? Select another Member? Or is this for a Report Variable? Or something else?


In a relational Model you coukld use the _day_of_week - function:
Quoteday_of_week ( date_expression, integer )
Returns the day of week (1 to 7), where 1 is the first day of the week as indicated by the second parameter (1 to 7, 1 being Monday and 7 being Sunday). Note that in ISO 8601 standard, a week begins with Monday being day 1.
Example: _day_of_week ( 2003-01-01 , 1 )
Result: 3

your condition will look like:

CASE WHEN
_day_of_week(#_add_days ($current_timestamp, -1 )# ) in (1,2,3,4,5) THEN 'Weekday'
ELSE 'Weekend'
END


Your Question is about Dimensional reporting but you give us only a macro-function...

schrotty


cognos05

Schrotty,

On result  I will show hide crosstab..

I already have this condition , I need to add an And to it and check if previousday is not a weekend, then show 1 else 0

if(cast(caption(tail (children([DailySales].[Day].[Day].[Day]->:[PC].[@MEMBER].[Day]),1)),integer) =#timestampMask(  _add_days ($current_timestamp, -1 )  , 'dd' ) #)
Then(1)
Else(0)

Thanks,
Nithya

cognos05

Schrotty ,

I got this working with the below code from your suggestion

if( _day_of_week (#_add_days ($current_timestamp, -7 )# ,1) in (1,2,3,4,5) )
Then(1)
Else(0)

so my requirement is to check if the month begins on a week end , say 1 st of any month  , then dont show the object

so its like I have to check if previous days date is 1 and then if its 1 then check if its weekend .

Thanks,
Nithya

schrotty