Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
nareshthavidishetty
Creator III
Creator III

Script error

Hi,

Below is the script used but when we reload it give the following error,

Untitled.png

Data:

LOAD

'' AS Dummy

AutoGenerate (0);

FOR EACH file in FileList('$(vFilePath)\*.xlsx');

ODBC CONNECT32 TO [Excel Files;DBQ=$(file)];

SheetNames:

SQLtables;

DISCONNECT;

FOR index = 0 to NoOfRows('SheetNames')-1

LET sheetNamez = PurgeChar(PurgeChar(Peek('TABLE_NAME', index, 'SheetNames'), Chr(39)), Chr(36));

Concatenate(Data)

Tab:

Load *,

  Month( GltPostingDate) as GltMonth,

    Year( GltPostingDate) as GltYear,

'MIS' as Misflag ,

'Capital' as Capflag,

GltAcctUnit&'-'&GltAccount&'-'&GltSubAccount as SheetName,

  '$(sheetNamez)' as Sheet_names

From $(file)(ooxml, embedded labels, table is [$(sheetNamez)]);

NEXT index

DROP TABLE SheetNames;

NEXT

DROP FIELD Dummy;

For Cal:

MinMax:

LOAD Min(GltPostingDate) as MinDate,

  Max(GltPostingDate) as MaxDate

Resident Data;

SET vFiscalYearStartMonth = 2;

LET vStartDate = Peek('MinDate');

LET vEndDate = Peek('MaxDate');

DROP Table MinMax;

FiscalCalendar:

LOAD *,

  Dual('Q' & Ceil(FIMonth/3), Ceil(FIMonth/3)) AS App_Quarter, // Fiscal Calendar Quarter

  Dual(Text(Date(MonthEnd(GltPostingDate), 'MMM')), FIMonth) AS GltPostingDate; // Fiscal Calendar Month Name

LOAD *,

  Year(GltPostingDate) AS Years, // Standard Calendar Year

  Month(GltPostingDate) AS Months,

   day(GltPostingDate) as App_Day,

  Date(MonthEnd(GltPostingDate), 'MMM') AS MonthName,  // Standard Calendar Month Name

  Dual('Q' & Ceil(Month(GltPostingDate)/3), Ceil(Month(GltPostingDate)/3)) AS Quarter,  // Standard Calendar Quarter

  Mod(Month(GltPostingDate) - $(vFiscalYearStartMonth), 12)+1 AS FIMonth,  // Fiscal Calendar Month

  YearName(GltPostingDate, 0, $(vFiscalYearStartMonth)) AS FIYear;  // Fiscal Calendar Year

LOAD Date($(vStartDate) + RangeSum(Peek('RowNum'), 1) - 1) AS GltPostingDate,

  RangeSum(Peek('RowNum'), 1) AS RowNum

AutoGenerate vEndDate - vStartDate + 1;

1 Solution

Accepted Solutions
sunny_talwar

I think the issue is here:

FiscalCalendar:

LOAD *,

  Dual('Q' & Ceil(FIMonth/3), Ceil(FIMonth/3)) AS App_Quarter, // Fiscal Calendar Quarter

Dual(Text(Date(MonthEnd(GltPostingDate), 'MMM')), FIMonth) AS GltPostingDate; // Fiscal Calendar Month Name

LOAD *,

  Year(GltPostingDate) AS Years, // Standard Calendar Year

  Month(GltPostingDate) AS Months,

  day(GltPostingDate) as App_Day,

  Date(MonthEnd(GltPostingDate), 'MMM') AS MonthName,  // Standard Calendar Month Name

  Dual('Q' & Ceil(Month(GltPostingDate)/3), Ceil(Month(GltPostingDate)/3)) AS Quarter,  // Standard Calendar Quarter

  Mod(Month(GltPostingDate) - $(vFiscalYearStartMonth), 12)+1 AS FIMonth,  // Fiscal Calendar Month

  YearName(GltPostingDate, 0, $(vFiscalYearStartMonth)) AS FIYear;  // Fiscal Calendar Year

LOAD Date($(vStartDate) + RangeSum(Peek('RowNum'), 1) - 1) AS GltPostingDate,

  RangeSum(Peek('RowNum'), 1) AS RowNum

AutoGenerate vEndDate - vStartDate + 1;

Rename the top one to call it something else:

Dual(Text(Date(MonthEnd(GltPostingDate), 'MMM')), FIMonth) AS GltPostingDateMonthName; // Fiscal Calendar Month Name

View solution in original post

3 Replies
sunny_talwar

I think the issue is here:

FiscalCalendar:

LOAD *,

  Dual('Q' & Ceil(FIMonth/3), Ceil(FIMonth/3)) AS App_Quarter, // Fiscal Calendar Quarter

Dual(Text(Date(MonthEnd(GltPostingDate), 'MMM')), FIMonth) AS GltPostingDate; // Fiscal Calendar Month Name

LOAD *,

  Year(GltPostingDate) AS Years, // Standard Calendar Year

  Month(GltPostingDate) AS Months,

  day(GltPostingDate) as App_Day,

  Date(MonthEnd(GltPostingDate), 'MMM') AS MonthName,  // Standard Calendar Month Name

  Dual('Q' & Ceil(Month(GltPostingDate)/3), Ceil(Month(GltPostingDate)/3)) AS Quarter,  // Standard Calendar Quarter

  Mod(Month(GltPostingDate) - $(vFiscalYearStartMonth), 12)+1 AS FIMonth,  // Fiscal Calendar Month

  YearName(GltPostingDate, 0, $(vFiscalYearStartMonth)) AS FIYear;  // Fiscal Calendar Year

LOAD Date($(vStartDate) + RangeSum(Peek('RowNum'), 1) - 1) AS GltPostingDate,

  RangeSum(Peek('RowNum'), 1) AS RowNum

AutoGenerate vEndDate - vStartDate + 1;

Rename the top one to call it something else:

Dual(Text(Date(MonthEnd(GltPostingDate), 'MMM')), FIMonth) AS GltPostingDateMonthName; // Fiscal Calendar Month Name

Anonymous
Not applicable

you define twice the field GltPostingDate

the first load above load all fields (include GltPostingDate) and creates new field GltPostingDate

LOAD *,

  Dual('Q' & Ceil(FIMonth/3), Ceil(FIMonth/3)) AS App_Quarter, // Fiscal Calendar Quarter

  Dual(Text(Date(MonthEnd(GltPostingDate), 'MMM')), FIMonth) AS GltPostingDate; // Fiscal Calendar Month Name

LOAD *,

  Year(GltPostingDate) AS Years, // Standard Calendar Year

  Month(GltPostingDate) AS Months,

   day(GltPostingDate) as App_Day,

  Date(MonthEnd(GltPostingDate), 'MMM') AS MonthName,  // Standard Calendar Month Name

  Dual('Q' & Ceil(Month(GltPostingDate)/3), Ceil(Month(GltPostingDate)/3)) AS Quarter,  // Standard Calendar Quarter

  Mod(Month(GltPostingDate) - $(vFiscalYearStartMonth), 12)+1 AS FIMonth,  // Fiscal Calendar Month

  YearName(GltPostingDate, 0, $(vFiscalYearStartMonth)) AS FIYear;  // Fiscal Calendar Year

LOAD Date($(vStartDate) + RangeSum(Peek('RowNum'), 1) - 1) AS GltPostingDate,

  RangeSum(Peek('RowNum'), 1) AS RowNum

AutoGenerate vEndDate - vStartDate + 1;

puttemans
Specialist
Specialist

is it possible you create 'Date($(vStartDate) + RangeSum(Peek('RowNum'), 1) - 1) AS GltPostingDate' while this variable already exists in your data table? Try renaming it to e.g. GltPostingDate1