Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
GraceGao
Creator
Creator

How to generate records in Qlik Sense

Hi experts

my data set as below, every product has budget by month, however, i would like to get every month's budget, if the budget is empty, need to generate records with 0 as below expected. Please help. 

 

GraceGao_0-1622014037225.png

 

1 Reply
GaryGiles
Specialist
Specialist

After loading the DataSet table, you could use the following load script, assuming you want 12 months of data:

Products:
Load Distinct Product
Resident DataSet;

Months:
Load RowNo() as Month
AutoGenerate(12);

for k=1 to NoOfRows('Products')
  Let vProduct = Peek('Product',k-1,'Products');
  Concatenate (DataSet)
  Load '$(vProduct)' as Product,
             Month,
             0 as Budget
Resident Months;
next k;

NoConcatenate
DataSetTemp:
Load Product, 
           Month,
           sum(Budget)
Resident DataSet
Group by Product, Month;

Drop table DataSet;
Rename table DataSetTemp to DataSet;
Drop tables Products, Months;