Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
379SSS
Contributor III
Contributor III

Dynamic Column Name in script level

Hi All,

I have a requirement like this.

Below are the field Names.

Pro_2023q3_ Actual,
Min_2023 _TargetPlan 

My Requirement is the hardcoded Values like Year, quarter has to change dynamically in the script level when the field names are updated with new quarter and year in the database.
Every quarter data gets updated with filed names as mentioned above. So, I want to make this field names should consider dynamically as in the database gets updated with latest one.

Need your inputs on this.

Labels (6)
3 Replies
marcus_sommer

Maybe with something like this:

let Y = year(today()); let Q = ceil(month(today()) / 3);

t: load Pro_$(Y)q$(Q)_ Actual, ...

379SSS
Contributor III
Contributor III
Author

Hi @marcus_sommersommer, 

I tried this but the thing is if database is not updated as per running days it should consider as same which is in database. 

Eg. If current year and quarter is 2023Q3, and in database it is updated till 2023Q1. So here it should dynamically pick which is in database.

marcus_sommer

I think there are several ways to get the wanted data. One would be to access the origin tables within the (source) data-base which contain very likely not changing date/timestamp fields instead of the prepared ETL views. Another could be to use the same prepare-instructions as the data-base which means the logic could be synchronized.

Further possible should be to access the various system-tables of the data-base which contain the information which tables/fields where exists and preparing with these information your load-statements. A similar approach could be also reached in Qlik by accessing all fields with a field-wildcard on a single record per First/Top statement in a pre-load and then looping through them and picking the needed ones.

If it are just a few days in which the field-names would be adjusted they might be fetched in a trial & error manner, for example by applying a loop which runs n times by changing with today()-n the base-date and the failing load-attempts are fetched per ERRORMODE.

In each case you will need some extra efforts.