Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
anonymous1
Contributor III
Contributor III

Table Not populating

hi, 

i have the following table:

FIRST_TABLE:
LOAD

PRODUCT_KEY,
COUNTRY,

STORE,
Date(MONTH, 'DD-MMM-YYYY') as MONTH,
num(AMOUNT) as AMOUNT,
'' as FLAG

FROM
[C:\sales_amount.qvd]
(qvd);

I need to create a new table that has all the PRODUCT_KEYS ending in 'A' from FIRST_TABLE and the FLAG column will now be populated with '1'.

 

Temp_AllCountries:
LOAD
Chr(39) & Concat(DISTINCT COUNTRY, Chr(39) & ',' & Chr(39)) & Chr(39) as ALL_COUNTRIES
resident FIRST_TABLE;

Let vAllCountries = FieldValue('ALL_COUNTRIES', 1);

DROP TABLE Temp_AllCountries;

for each vCountry in '$(vAllCountries)'

NEW_TABLE:
LOAD

PRODUCT_KEY as Product_Key,
COUNTRY as Country,

STORE as Store,
Date(MONTH, 'DD-MMM-YYYY') as Month,
num(AMOUNT) as Amount,
1 as Flag


resident FIRST_TABLE
where right(PRODUCT_KEY, 1) = 'A'
and COUNTRY = '$(vCountry)';

NEXT

....

so my problem is that NEW_TABLE isn't populating.  any ideas why?

Labels (2)
4 Replies
Miguel_Angel_Baeyens

Which errors do you see when debugging the script? Do the variables populate correctly and loop through every possible value?

What if you do the load manually to make sure that filters in WHERE apply correctly?

That code looks very familiar, did you check for missing quotes, commas, etc.?

anonymous1
Contributor III
Contributor III
Author

there are no errors, and the variable populates correctly. i can also confirm the WHERE clause works aswell.  i assumed the loop was the problem? im very new to QlikView so i cant see what it is Ive done wrong

pepecc
Contributor III
Contributor III

Try cleaning spaces at the end of product_key in your where clause. Something like this:

 

resident FIRST_TABLE
where right(rtrim(PRODUCT_KEY), 1) = 'A'
and COUNTRY = '$(vCountry)';

 

Hope it helps.

 

 

Brett_Bleess
Former Employee
Former Employee

Only extra thing I have is the following link:

https://community.qlik.com/t5/Qlik-Design-Blog/Loops-in-the-Script/ba-p/1473543

There are other posts in this area, so feel free to search yourself, just back the URL up to the Qlik-Design-Blog/ level and you can search from there.  If the poster above me was correct, please be sure to give them credit by using Accept as Solution button to mark the post...

If you figured out something else, you can post that and mark it as the solution as well.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.