Skip to main content

Hi All,

 

In my dataset I have a field “Opened On” which is a date field. 

 

I have sent my date properties so that the week starts from Friday. 

 

I want to aggregate the data for every weekend and the aggregation should include the present Friday and all the weekdays before the previous Friday ie. exclude the previous Friday. 

 

For example:

 

So for the date April17 (which is a Friday) the aggregation should only  count of rows from April9 to April17. 

(Since April10 is a Friday and rows for this date should not be considered).

 

I used the formula [Aggregation] -

 

COUNT(if [Opened On] = DATE(DATETRUNC('week', [Opened On], 'Thursday'))  then [Number of Records] end ) +

 

COUNT(if [Opened On] = DATE(DATETRUNC('week', [Opened On], 'Wednesday'))  then [Number of Records] end ) +

 

COUNT(if [Opened On] = DATE(DATETRUNC('week', [Opened On], 'Tuesday'))  then [Number of Records] end ) +

 

COUNT(if [Opened On] = DATE(DATETRUNC('week', [Opened On], 'Monday'))  then [Number of Records] end ) +

 

COUNT(if [Opened On] = DATE(DATETRUNC('week', [Opened On], 'Saturday')) then [Number of Records] end ) +

 

COUNT(if [Opened On] = DATE(DATETRUNC('week', [Opened On], 'Sunday')) then [Number of Records] end )+

 

COUNT(if [Opened On] = DATE(DATETRUNC('week', [Opened On], 'Friday'))  then [Number of Records] end )

 

But this formula is including the previous Friday and excluding the present Friday.

So for example for April17 the above formula is considering the count of all rows from April10 to April16. However, I would like to count all the rows from April 9 to April 17 instead.

 

My dataset contains three weekends - April 3  April 10 and April17.

I am getting values 8 27 and17 respectively  however the desired values are  9, 28,19.

 

I have attached my workbook along with this mail.

 

Can someone please suggest how to include the Present Friday and exclude the Previous Friday for a weekend date as shown above. 

 

Thanking you all !

 

Regards,

Rishi Saka

16 个回答
0/9000