Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
inam
Contributor III
Contributor III

restrict previous month date data

Hello Community,

i am taking 4 expression for calculate last 4 date data. see below code . and i have raw data last month to today-1 (1st july to 17 aug)

=if(day(Today())=1,
Num((Count({< Floor_DC = {"=floor(Date(MonthEnd(Now()-1)-3,'DD-MM-YYYY')) "}>} PROD_TYPE)),'##'),
Num((Count({< Floor_DC = {">=$(=((floor(date(Max(Now()- 4)))))) <=$(=(floor(Date(Now()-4))))"}>} PROD_TYPE)),'##'))

=if(day(Today())=1,
Num((Count({< Floor_DC = {"=floor(Date(MonthEnd(Now()-1)-2,'DD-MM-YYYY')) "}>} PROD_TYPE)),'##'),
Num((Count({< Floor_DC = {">=$(=((floor(date(Max(Now()- 3)))))) <=$(=(floor(Date(Now()-3))))"}>} PROD_TYPE)),'##'))

=if(day(today())=1,
Num((Count({< Floor_DC = {"=floor(Date(MonthEnd(Now()-1)-1,'DD-MM-YYYY')) "}>} PROD_TYPE)),'##'),
Num((Count({< Floor_DC = {">=$(=((floor(date(Max(Now()- 2)))))) <=$(=(floor(Date(Now()-2))))"}>} PROD_TYPE)),'##'))

=if(day(today())=1,
Num((Count({< Floor_DC = {"=floor(date(MonthEnd(Now()-1),'DD-MM-YYYY')) "}>} PROD_TYPE)),'##'),
Num((Count({< Floor_DC = {">=$(=((floor(date(Max(Now()- 1)))))) <=$(=(floor(Date(Now()-1))))"}>} PROD_TYPE)),'##'))

and its working fine if the date is 1st august is show last 4 date data.

but i want if the date is 2 august is show only current month date data other colum shows '0' see below example

If TODAY DATE IS 2 AUGUST      
         
c product  29-07-2023 30-07-2023 31-07-2023 01-08-2023
a 0 0 0 5
b 0 0 0 10
c 0 0 0 6

 

If TODAY DATE IS 3 AUGUST      
         
c product  30-07-2023 31-07-2023 01-07-2023 02-08-2023
a 0 0 5 115
b 0 0 10 101
c 0 0 6 65

 

If TODAY DATE IS 4 AUGUST      
         
c product  31-07-2023 01-07-2023 02-07-2023 03-08-2023
a 0 5 115 45
b 0 10 101 69
c 0 6 65 70

 

i want if date is 1 show last 4 days value

if date is 2,3,4 last 4 date value but only current month

for example :-

if today date 1st august show last 4 date data july 28,29,30,31 all values

if today date is 2 august show last 4 date data 29,30,31,1 but here show only 1st august data i want other column 0

if date is 3 august show last 4 date data 30,31,1,2 so only show 1&2 data i want other column (30,31) 0

if date is 4 august show last 4 date data 31,1,2,3 so only show 1,2&3 data i want other column (31) 0

if date is 5 august show last 4 days data 1,2,3,4 all value

Labels (1)
1 Reply
Or
MVP
MVP

Perhaps I'm reading it incorrectly, but your expressions are confusing to me. In particular:

{">=$(=((floor(date(Max(Now()- 4)))))) <=$(=(floor(Date(Now()-4))))"}>}

* What's the point of Max(Now())? There's only one value of Now(), why would you use Max() here?

* Why use Date() here? It's a formatting function, and you're flooring the result anyway so it'll end up being numeric. This shouldn't do any harm but it doesn't actually do anything except add clutter.

* Both of these values appear to be the same when you ignore said Max(), meaning no values will ever fall within the range unless they happen at exactly midnight on the specified day. I think the second part of this statement shouldn't subtract 4 from Now()?

* If you want to only get days within the month, you could use RangeMax(MonthStart(Now()),Floor(Now()-4)) to pick out the larger of the two values (on the 6th, this will pick out now()-4, but on the 3rd, it'll pick out the 1st).