Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
posywang
Creator
Creator

How to create a variable in script?

Hi,

It is probably an easy one for these who know. I can't figure out how to create a variable in script for current fiscal month. This variable will be used in other script (not included in this example) to determine which value to be pulled. It would be great if variable value stays and Date table goes away. Thank you.

1 Solution

Accepted Solutions
tomasz_tru
Specialist
Specialist

LET vToday=  today(1);

ControlTable:
Load * Inline [
Month;Start;End;"Fiscal Year"
1;12.12.2016;15.01.2017;2017
2;16.01.2017;12.02.2017;2017
3;13.02.2017;12.03.2017;2017
4;13.03.2017;16.04.2017;2017
5;17.04.2017;14.05.2017;2017
6;15.05.2017;11.06.2017;2017
7;12.06.2017;16.07.2017;2017
8;17.07.2017;13.08.2017;2017
9;14.08.2017;10.09.2017;2017
10;11.09.2017;15.10.2017;2017
11;16.10.2017;12.11.2017;2017
12;13.11.2017;10.12.2017;2017
1;11.12.2017;14.01.2018;2018
2;15.01.2018;11.02.2018;2018
3;12.02.2018;11.03.2018;2018
4;12.03.2018;15.04.2018;2018
5;16.04.2018;13.05.2018;2018
6;14.05.2018;10.06.2018;2018
7;11.06.2018;15.07.2018;2018
8;16.07.2018;12.08.2018;2018
9;13.08.2018;09.09.2018;2018
10;10.09.2018;14.10.2018;2018
11;15.10.2018;11.11.2018;2018
12;12.11.2018;09.12.2018;2018
](delimiter is ';');

TempTable: 
LOAD "Fiscal Year"
Resident ControlTable
WHERE '$(vToday)' >= Date#(Start,'DD.MM.YYYY') AND '$(vToday)' <= Date#(End,'DD.MM.YYYY');

LET vFiscalYear = Peek('Fiscal Year',0,TempTable);

DROP TABLE TempTable, ControlTable;

View solution in original post

4 Replies
tomasz_tru
Specialist
Specialist

LET vToday=  today(1);

ControlTable:
Load * Inline [
Month;Start;End;"Fiscal Year"
1;12.12.2016;15.01.2017;2017
2;16.01.2017;12.02.2017;2017
3;13.02.2017;12.03.2017;2017
4;13.03.2017;16.04.2017;2017
5;17.04.2017;14.05.2017;2017
6;15.05.2017;11.06.2017;2017
7;12.06.2017;16.07.2017;2017
8;17.07.2017;13.08.2017;2017
9;14.08.2017;10.09.2017;2017
10;11.09.2017;15.10.2017;2017
11;16.10.2017;12.11.2017;2017
12;13.11.2017;10.12.2017;2017
1;11.12.2017;14.01.2018;2018
2;15.01.2018;11.02.2018;2018
3;12.02.2018;11.03.2018;2018
4;12.03.2018;15.04.2018;2018
5;16.04.2018;13.05.2018;2018
6;14.05.2018;10.06.2018;2018
7;11.06.2018;15.07.2018;2018
8;16.07.2018;12.08.2018;2018
9;13.08.2018;09.09.2018;2018
10;10.09.2018;14.10.2018;2018
11;15.10.2018;11.11.2018;2018
12;12.11.2018;09.12.2018;2018
](delimiter is ';');

TempTable: 
LOAD "Fiscal Year"
Resident ControlTable
WHERE '$(vToday)' >= Date#(Start,'DD.MM.YYYY') AND '$(vToday)' <= Date#(End,'DD.MM.YYYY');

LET vFiscalYear = Peek('Fiscal Year',0,TempTable);

DROP TABLE TempTable, ControlTable;

tomasz_tru
Specialist
Specialist

I can't edit post: change Fiscal Year to Month in lines 33 and 37.

posywang
Creator
Creator
Author

Thanks, peek function works like a charm!

kesavagopalam123
Contributor
Contributor

how to create a variable to entire table