Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
bsharma_velcro
Contributor III
Contributor III

Entering dummy rows in a table

Hi,

I need to insert some dummy rows in a table (at the back end) based on a condition.

Every month I get forecast data for current month and next 11 months. So, in January I have Forecast data from January till December. In February, I have Forecast from February to January next year...so on and so forth.

From February onwards, I need to insert dummy rows in my data so that no matter which month the forecast is getting created, I have "Forecast For Month" column with all the months for the current year. So, for February, I need to add 1 dummy row with 0 as Forecast value, for March, I need to add 2 dummy rows,.... as shown in the output.

Row Data:

bsharma_velcro_0-1761749841228.png

Output:

bsharma_velcro_2-1761750779258.png

Appreciate any help with the script.

Regards,

BS

 

Labels (2)
1 Solution

Accepted Solutions
Daniel_Castella
Support
Support

Hi @bsharma_velcro 

 

Try this code, the output appears well to me:

 

A:
LOAD
"Creation Date",
"Forecast Date",
Value
FROM [lib://DataFiles/Inserting Dummy Rows.xlsx]
(ooxml, embedded labels, table is RawData);


B:
LOAD "Creation Date"
RESIDENT A;

OUTER JOIN (B)
LOAD "Creation Date" as "Forecast Date",
'0' as Value
RESIDENT A;

Concatenate (A)
LOAD *
RESIDENT B
Where num("Creation Date")>num("Forecast Date");

DROP TABLE B;

 

Kind Regards

Daniel

 

Daniel_Castella_0-1761839289628.pngDaniel_Castella_1-1761839342180.png

 

View solution in original post

2 Replies
HirisH_V7
Master
Master

Hi something like this,

TempRange:
LOAD
    Min(MonthStart(Date#(MonthName, 'MMM-YYYY'))) as MinMonth,
    Max(MonthStart(Date#(MonthName, 'MMM-YYYY'))) as MaxMonth
Resident Data;

AllMonths:
LOAD 
    Date(AddMonths(MinMonth, IterNo() - 1), 'MMM-YYYY') as Forecast_Month_Name
While AddMonths(MinMonth, IterNo() - 1) <= MaxMonth;
Resident TempRange

Left Join (AllMonths)
LOAD 
    Date#(MonthName, 'MMM-YYYY') as MonthDate,
    Forecast_Month_Name,
    <Rest other fields here>
Resident Data;
DROP Table TempRange;

 

HirisH
Daniel_Castella
Support
Support

Hi @bsharma_velcro 

 

Try this code, the output appears well to me:

 

A:
LOAD
"Creation Date",
"Forecast Date",
Value
FROM [lib://DataFiles/Inserting Dummy Rows.xlsx]
(ooxml, embedded labels, table is RawData);


B:
LOAD "Creation Date"
RESIDENT A;

OUTER JOIN (B)
LOAD "Creation Date" as "Forecast Date",
'0' as Value
RESIDENT A;

Concatenate (A)
LOAD *
RESIDENT B
Where num("Creation Date")>num("Forecast Date");

DROP TABLE B;

 

Kind Regards

Daniel

 

Daniel_Castella_0-1761839289628.pngDaniel_Castella_1-1761839342180.png