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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
amien
Specialist
Specialist

reading excel and ROWNO() / RECNO()

I have an excel file with for every week a sheet. I read all these sheets with a loop.

I only take 5 rows of each sheet. I take these 5 rows based on a certain WHERE clause. I only take the rows where a certain column is not empty.

The result will be a table with 5 rows for each week and a value.

Based on the filename i have the year. Based on the sheet name i have the week. Now i'm looking for the day to create a date.

Using MAKEWEEKDATE to create the date. the day is only causing an issue. the 5 rows that i read are always in the right order (mon,tue,wed etc).

But how do i create a number of that (0,1,2,..) . ROWNO and RECNO don't work. Also tried to create something with AUTONUMBER, but wasn't solving it

Anyone got a solution for this?

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try a preceding load:

LOAD      *,

               makeweekdate(Year, Week, recno() ) as Date;

LOAD Year, Week, Value FROM ... where ...;

View solution in original post

6 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Perhaps you can use the weekday function on the result of the makeweekdate to get the day of the week. That's a dual value so it can be sorted numerically (or you can use the num function on it to get the weekday number).


talk is cheap, supply exceeds demand
amien
Specialist
Specialist
Author

Gysbert, the problem is that i'm looking for the makeday. I don't have a valid date for makeday

MAKEWEEKDATE('2013','22','1')

MAKEWEEKDATE('2013','22','2')

MAKEWEEKDATE('2013','22','3')

MAKEWEEKDATE('2013','22','4')

MAKEWEEKDATE('2013','22','5')

2013 is based on the filename, 22 on sheetname, 1...5 on ??

what i basicly need is a row counter while looping though each sheet. A new sheet should reset the counter. I only read 5 rows on each sheet (reduced on WHERE clause). I was hoping ROWNO or RECNO would solve this, but this is not the case

perhaps i misunderstood you?

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

More likely I'm misunderstanding you . I can't see the files or data you have to work with. Maybe mod(recno(),5) gives you the numbers you need.


talk is cheap, supply exceeds demand
swuehl
MVP
MVP

Try a preceding load:

LOAD      *,

               makeweekdate(Year, Week, recno() ) as Date;

LOAD Year, Week, Value FROM ... where ...;

amien
Specialist
Specialist
Author

i think the best solution is indeed a precedent load .. all the records are in the correct order.

the mod solution works almost but not in all cases (i have several excel files each with 52 weeks).

but the RECNO() with WHERE won't work? because i think the second monday will have a 6 instead of a 0.

can i do a counter in the preceding loading?

somethink like : IF(PREVIOUS(DayValue) = 5,0,PREVIOUS(DayValue)+1)

Only problem is that DayValue doesn't exist yet

amien
Specialist
Specialist
Author

i fixed it with a precent load, previous and peek

Thanks both