Qlik Community

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
QlikWorld 2022, LIVE in Denver CO., May 16-19, 2022. REGISTER NOW TO RECEIVE EARLY BIRD PRICING
cancel
Showing results for 
Search instead for 
Did you mean: 
Nayarett
Contributor
Contributor

how I can create a variable connection?.

Hi everyone,

I need help. how I can create a variable connection?.
It's a data source build everyday by a bot.

These folders are with this structure:

$Year/$Month/$Day/archivo_$Year_$Month_$Day.xls

(Month ='00')
(Day='00')

I resolved for $Year with:

"LET vFrom=2020;"
LET vTo=Year(Today());

For vAño=$(vFrom) to $(vTo) "

But It's'nt working for $Month and $Year


Could anyone help me, please?

1 Reply
rubenmarin

Hi to read all files from a estructure you can use a code like the example 2 of this link:

https://help.qlik.com/en-US/qlikview/May2021/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptC...

Keeping you strategy you can use nested for's, like:

FOR vAño=$(vFrom) to $(vTo)
  FOR vMes=1 to 12
    LET vMesCarga=Num(MakeDate($(vAño),$(vMes)));
    LET vMaxDia=Day(MonthEnd($(vMesCarga)));
    FOR vDia=1 to $(vMaxDia)
      LOAD...
      From [PathToStructure\$(vAño)\$(vMes)\$(vDia)\archivo_$(vAño)_$(vMes)_$(vDia).xls]
(....)
    NEXT
  NEXT
NEXT

Executed today this will read from 1/1/2020 to 31/07/2021, it may need some fixes to control files that may not exist, using the first option (the help page example) you can avoid most issues, you can use FileName() to extract year, month and day from xls file name.