Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Current day-7 days logic

Dear Friends,

I have a date field. I wanted to show  max(date) - 7 days in a list box. I wanted to list all the previous 7 days dates in the listbox.

I used this expression but not giving me result properly.

Temp:

load Snapshot_Year_CurrentDay,CurrentQuarter,Snapshot_date;

select max(snapshot_date) as Snapshot_Year_CurrentDay,

max(Financial_Close_Fiscal_Year_Quarter_Code) as CurrentQuarter,

max(snapshot_date) as Snapshot_date

from PERSONAL_SERVICE.FACT_TABLE;

let vActualsAsOf=peek('Snapshot_date',0,'Temp');

Let v_Max=peek('Snapshot_date');

drop Table Temp;

Actual_Revenue_Tmp:

SELECT

    snapshot_date

 

FROM PERSONAL_SYSTEMS_ATTACH_SERVICE.FACT_SV_HW_ORDER_EX_DBRD_QTR_DOD ;

MaxDate:

Load Max(snapshot_date) As MaxDate

Resident Actual_Revenue_Tmp;

Let v_Max=peek('MaxDate');

Drop Table MaxDate;

Asof:

LOAD

Date($(v_Max) - iterno() + 1) as Last7Date

AutoGenerate(1)

while iterNo() < 7

Last7Date is not giving me proper result. can any1 help here.???please

1 Reply
swuehl
MVP
MVP

What do you mean with 'not giving me proper result' exactely?

Start with checking the MaxDate table, if the MaxDate has been loaded correctly. Comment the Drop Table MaxDate; and check the records in table viewer.

Then check the variable that fetches the MaxDate ( I would also write it like this):

Let v_Max=Floor(Peek('MaxDate',0,'MaxDate'));