Last active
April 17, 2022 06:36
-
-
Save countnazgul/9fecb31092ac14a52b06 to your computer and use it in GitHub Desktop.
[Generate all previous months] For each month in the given months list, generate all previous months #qlik #qliksense #qlikview #script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Raw: | |
Load * Inline [ | |
Month | |
2014-01 | |
2014-02 | |
2014-03 | |
2014-04 | |
2014-05 | |
]; | |
NoConcatenate | |
TempTable1: | |
Load Distinct | |
date(Date#(Month, 'YYYY-MM')) as Month | |
Resident | |
Raw | |
Order By | |
Month | |
; | |
Drop Table Raw; | |
let vMinMonth = date(FieldValue('Month',1)); | |
for i = 1 to FieldValueCount('Month') | |
let vMonth = FieldValue('Month',i); | |
let vMonthDiff = ((year(date('$(vMonth)'))*12)+month(date('$(vMonth)'))) - (((year(date('$(vMinMonth)'))*12)+month(date('$(vMinMonth)')))) ; | |
for a = 0 to vMonthDiff | |
Test: | |
Load | |
'$(vMonth)' as Month, | |
AddMonths(date('$(vMonth)'), -$(a)) as PreviousMonths | |
AutoGenerate(1); | |
next | |
next | |
Drop Table TempTable1; | |
let a = Null(); | |
let i = Null(); | |
let vMonthDiff = Null(); | |
let vMonth = Null(); | |
let vMinMonth = Null(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment