Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
canoebi99
Partner - Creator
Partner - Creator

Need the formula to set a field selection to the weekending date of today in the reporting service.

Hi all, 

I have created a report via the reporting service and I would like to select the current weekending date in one of the selection fields. 

I cannot work out what I need to put in the date formula to acheive this? It needs to be dynamic always working from todays date. 

Can anyone help with the formula I would need to use please?  I have tried using weekend(today) and weekend(now) but it doesn't seem to be happy with that. Is there a way to achieve this?

Many thanks.

Labels (2)
2 Replies
hic
Former Employee
Former Employee

The date of the last day of the week can be calculated by
    Date(Floor(WeekEnd(Today())))
or
    Date(WeekStart(Today(),1)-1)

It is however unclear how you want to use this. One way could be to use it in a set expression:
    Sum({<Date={"$(=Date(WeekStart(Today(),1)-1))"}>} Amount)
Then the measure will be calculated for this date only.
But since the day hasn't occurred yet, the result will probably be an empty set...

canoebi99
Partner - Creator
Partner - Creator
Author

Thanks for the repsone Henric, however my question is specific to the date formula in the reporting service "set selection on report" area and it appears our usual qlik formulas do not work in here:

It is within the reporting service “Add Selection to Report” that I am trying to set a field called WeekEnding to be the last day of the current week.

Below you can see I have used now and the format M Y to get set a Roll Month field and this seems to work ok (so for today it will set the RollMonth field as May 2022).

canoebi99_0-1651526356494.png

 

My question is how do I set the WeekEnding selection in the reporting service with the current week ending date.

I can do this with hard coding if I use “now + x days” (where x is the number of days to the weekending of the date I want – shown below) but I need to do this dynamically. i.e. get the weekending date of the current week each day the report runs because this report will be scheduled to run each day and it should always run for the current week ending selection.

canoebi99_1-1651526356693.png

 

If I try to use the code we would usually use within Qlik as below it does not work.

canoebi99_2-1651526356844.png

 

The weekending selection is not set to anything (as shown in the output below):

canoebi99_3-1651526356867.png

 

Hence, I need to know what the formula in the reporting service is to get the weekending date of today if anyone can help with that.

Many Thanks.