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

How to display previous month data for current month if no data for current month

Hi All,

I have chart for last 6th month count(Workers)

issue:i dont have data for July Month

i want to show June data  for  July also.

if there is no data for Any Month need to take previus month data .

How to achieve this

please find the application sample

8 Replies
Not applicable
Author

Hi Raj,

Try appending this to your script.

LOAD *,Date(AddMonths(MonthName, IterNo()), 'MMM YYYY') as MonthName

    

While AddMonths(MonthName, IterNo())<NextMonth; 

LOAD *, 

    Previous(MonthName) as NextMonth 

Resident HeadCount

Order By [Worker ID],MonthName Desc;

Hope it helps.

Regards,

Pratik

Not applicable
Author

iam not able to get desired solution,

can u post sample

Not applicable
Author

Hi Raj,

Try This:

HeadCount:

LOAD

     [Job Posting Title],

     [Worker: Worker Supervisor],

     [Worker: Worker Supervisor] as [Hiring Manager],

     Worker,

     [Worker ID],

     Status,

     [Start Date],

     [End Date],

     Month([Start Date]) as Month,

     month([End Date]) as DOR,

     Year(([Start Date])) as Year,

     MonthName([Start Date]) as MonthName,

     MonthName([End Date]) as MonthName1,

     today() as CM,

     AddMonths(today(),-6) as R6M,

     'Q' & ceil(Month([End Date])/3) as Quarter,

     "Current Bill Rate [ST/Hr]",

     [Physical Location of Worker],

     [Worker Closed Date],

     [Cumulative Committed Spend],

     [Total Spend]

FROM

(biff, embedded labels, table is Headcount$, filters(

Remove(Row, RowCnd(CellValue, 4, StrCnd(null)))

));

///// New Script to be added after your table..

LOAD [Job Posting Title],

     [Worker: Worker Supervisor],

     [Worker: Worker Supervisor] as [Hiring Manager],

     Worker,

     [Worker ID],

     Status,

     [Start Date],

     [End Date],

     Month([Start Date]) as Month,

     month([End Date]) as DOR,

     Year(([Start Date])) as Year,

     Date(AddMonths(MonthName, IterNo()), 'MMM YYYY') as MonthName,

     MonthName([End Date]) as MonthName1,

     today() as CM,

     AddMonths(today(),-6) as R6M,

     'Q' & ceil(Month([End Date])/3) as Quarter,

     "Current Bill Rate [ST/Hr]",

     [Physical Location of Worker],

     [Worker Closed Date],

     [Cumulative Committed Spend],

     [Total Spend]

   

While AddMonths(MonthName, IterNo())<=NextMonth;

LOAD *,

    if(Month<MonthName(Today()) and Month=MonthName(AddMonths(Today(),-1)),MonthName(Today())) as NextMonth 

Resident HeadCount

Order By [Worker ID],MonthName Desc;

If this doesnt give the desired result then post ur excel with dummy data if possible..

Regards,

Pratik

Not applicable
Author

Hi Pratik ,

Thanks for your Time.

please find the data files

Thanks in advance

Not applicable
Author

Hi Raj,

Try This:

HeadCount:

LOAD

     [Job Posting Title],

     [Worker: Worker Supervisor],

     [Worker: Worker Supervisor] as [Hiring Manager],

     Worker,

     [Worker ID],

     Status,

     [Start Date],

     [End Date],

     Month([Start Date]) as Month,

     month([End Date]) as DOR,

     Year(([Start Date])) as Year,

     MonthName([Start Date]) as MonthName,

     MonthName([End Date]) as MonthName1,

     today() as CM,

     AddMonths(today(),-6) as R6M,

     'Q' & ceil(Month([End Date])/3) as Quarter,

     "Current Bill Rate [ST/Hr]",

     [Physical Location of Worker],

     [Worker Closed Date],

     [Cumulative Committed Spend],

     [Total Spend]

FROM

(biff, embedded labels, table is Headcount$, filters(

Remove(Row, RowCnd(CellValue, 4, StrCnd(null)))

));

///// New Script to be added after your table..

LOAD [Job Posting Title],

     [Worker: Worker Supervisor],

     [Worker: Worker Supervisor] as [Hiring Manager],

     Worker,

     [Worker ID],

     Status,

     [Start Date],

     [End Date],

     Month([Start Date]) as Month,

     month([End Date]) as DOR,

     Year(([Start Date])) as Year,

     Date(AddMonths(MonthName, IterNo()), 'MMM YYYY') as MonthName,

     MonthName([End Date]) as MonthName1,

     today() as CM,

     AddMonths(today(),-6) as R6M,

     'Q' & ceil(Month([End Date])/3) as Quarter,

     "Current Bill Rate [ST/Hr]",

     [Physical Location of Worker],

     [Worker Closed Date],

     [Cumulative Committed Spend],

     [Total Spend]

  

While AddMonths(MonthName, IterNo())<=NextMonth;

LOAD *,

    if(MonthName <MonthName(Today()) and MonthName =MonthName(AddMonths(Today(),-1)),MonthName(Today())) as NextMonth

Resident HeadCount

Order By [Worker ID],MonthName Desc;

Not applicable
Author

I tried it worked.

Let me know if that worked for you.

Regards,

Pratik

Not applicable
Author

can u post the application

thanks

my Script:

HeadCount:

LOAD CM,

     [Cumulative Committed Spend],

     "Current Bill Rate [ST/Hr]",

     DOR,

     [End Date],

     [Hiring Manager],

     [Job Posting Title],

     Month,

    MonthName,

      //Date(AddMonths(MonthName, IterNo()), 'MMM YYYY') as MonthName,

     MonthName1,

     [Physical Location of Worker],

     Quarter,

     R6M,

     [Start Date],

     Status,

     [Total Spend],

     Worker,

     [Worker Closed Date],

     [Worker ID],

     [Worker: Worker Supervisor],

     Year

FROM

[31-07-2015\head.xlsx]

(ooxml, embedded labels, table is Sheet1);

Resident1:

LOAD *,

    if(MonthName <MonthName(Today()) and MonthName =MonthName(AddMonths(Today(),-1)),MonthName(Today())) as NextMonth

Resident HeadCount

Order By [Worker ID],MonthName Desc;

drop table HeadCount;

Actual:

LOAD [Job Posting Title],

     [Worker: Worker Supervisor],

     [Worker: Worker Supervisor] as [Hiring Manager],

     Worker,

     [Worker ID],

     Status,

     [Start Date],

     [End Date],

     Month([Start Date]) as Month,

     month([End Date]) as DOR,

     Year(([Start Date])) as Year,

     Date(AddMonths(MonthName, IterNo())) as MonthName,

     MonthName([End Date]) as MonthName1,

     today() as CM,

     AddMonths(today(),-6) as R6M,

     'Q' & ceil(Month([End Date])/3) as Quarter,

     "Current Bill Rate [ST/Hr]",

     [Physical Location of Worker],

     [Worker Closed Date],

     [Cumulative Committed Spend],

     [Total Spend]

     resident Resident1 While AddMonths(MonthName, IterNo())<=NextMonth;

     drop table Resident1;

Not applicable
Author

Hi Raj,

Sorry I can post app. I have tried doing it again using your script. I am getting the values for july. Since the month of august has started your excel data will comprise of July months data which you will be wanting to show for the month of august as well right. So I added two records in the head.xlsx sheet below are the records:

CMCumulative Committed SpendCurrent Bill Rate [ST/Hr]DOREnd DateHiring ManagerJob Posting TitleMonthMonthNameMonthName1Physical Location of WorkerQuarterR6MStart DateStatusTotal SpendWorkerWorker Closed DateWorker IDWorker: Worker SupervisorYear
8/30/201510966.821.09Aug8/28/2015Ebwkgaovrc, IpatppIT Intern - non CAJulJul 2015Aug 2015Berkeley Heights, NJ - 300Q31/30/20157/1/2015Open0Siegert, RebeccaCELGWK00001663Gibzrepfkk, Nrphlz2015
8/30/201511625.8421.69Sep9/1/2015Cngbshcadq, DepeuIT Intern - non CAJulJul 2015Sep 2015Berkeley Heights, NJ - 300Q31/30/20157/1/2015Open0Patel, BijalCELGWK00001661Ehqomjfgcq, Dzkvp2015

If now you will get these two records which I added for july in the month of august(Current Month) as well.

If you see in the HeadCount tables script I have commented the MonthName field and derived a MonthName field from start date, which offcourse you are doing in excel, I purposely did that because if I am using the MonthName field I am getting wrong counts maybe because of Data issue(Syntax in MonthName field). Not sure. So I used the derived field. You can check for yourself by uncommenting the MonthName and Commenting the Derived MonthName field for your reference. When doing this also dont forget to comment and uncomment the MonthName similarly in the Below script of Preceding Load.

HeadCount:

LOAD CM,

    [Cumulative Committed Spend],

    "Current Bill Rate [ST/Hr]",

    DOR,

    [End Date],

    [Hiring Manager],

    [Job Posting Title],

    Month,

    //MonthName,

      MonthName([Start Date]) as MonthName,

    MonthName1,

    [Physical Location of Worker],

    Quarter,

    R6M,

    [Start Date],

    Status,

    [Total Spend],

    Worker,

    [Worker Closed Date],

    [Worker ID],

    [Worker: Worker Supervisor],

    Year

FROM

\\MSAD\ROOT\EU\LN\USERS\pratic\Desktop\head.xlsx

(ooxml, embedded labels, table is Sheet1);

LOAD CM,

    [Cumulative Committed Spend],

    "Current Bill Rate [ST/Hr]",

    DOR,

    [End Date],

    [Hiring Manager],

    [Job Posting Title],

    Month,

  

    //AddMonths(MonthName, IterNo()) as MonthName,

    Date(AddMonths(MonthName, IterNo()), 'MMM YYYY') as MonthName,

  

    MonthName1,

    [Physical Location of Worker],

    Quarter,

    R6M,

    [Start Date],

    Status,

    [Total Spend],

    Worker,

    [Worker Closed Date],

    [Worker ID],

    [Worker: Worker Supervisor],

    Year

  

While AddMonths(MonthName, IterNo())=NextMonth;

LOAD *,

    if(MonthName<MonthName(Today()) and MonthName=MonthName(AddMonths(Today(),-1)),MonthName(Today())) as NextMonth

Resident HeadCount ;

Regards,

Pratik