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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
pjn123pjn123
Contributor III
Contributor III

Right Function with File Name - Detect file extention

Hi

I'm struggling detecting when a file is xlsx or xls.

For some reason the first line also selects the *.xlsx files so I thought I would fix it by adding a IF ELSE statement.

But my IF statement below is always FALSE.

It probably have something to do with my use of the right() function

Thanks for this forum - Really learning a lot!

QlikView Script Code:

let path_Alles = 'C:\Users\xxx\Desktop\xxx\*.xls';

for each File in filelist (path_Alles)

SET sFile = '$(File)';

IF Right($(sFile),4)="xlsx" THEN

FindHeaderTemp:

LOAD RecNo() as DataStart

FROM $(File)

(ooxml, no labels)

WHERE A = 'Earning Year';

ELSE

FindHeaderTemp:

LOAD RecNo() as DataStart

FROM $(File)

(biff, no labels)

WHERE @1 = 'Earning Year';

EndIf         

1 Solution

Accepted Solutions
sunny_talwar

May be try this:

IF Right('$(sFile)', 4) = 'xlsx' then

or

IF SubField('$(sFile)', '.', -1) = 'xlsx' then

View solution in original post

2 Replies
sunny_talwar

May be try this:

IF Right('$(sFile)', 4) = 'xlsx' then

or

IF SubField('$(sFile)', '.', -1) = 'xlsx' then

pjn123pjn123
Contributor III
Contributor III
Author

Thanks Sunny - Worked perfectly. Will need to restudy my understanding of the ' & ".

Thanks for the quick help!