Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

gayatri7
Contributor II

Current Period and Previous Period in the script

Hi All,

I have a period column which contains value like 201708,201709,201710 etc.

I have to extract the value from another file based on the current period only.

Eg. In file A I have Period columns contain 201708,201709,201710 etc. where as in file B I have entire history details and need to extract only the data for Current month. and for some related to previous month

I have created a variable as shown below

vCurrentYear: Left([PERIODO],4)

vCurrentMonth: Right([PERIODO],2)

vPreviousYear: Left([PERIODO]-1),4)

vPreviousMonth: Right(([PERIODO]-1),2)

For Previous month and year variable is not working at the script level where as it is working fine in text object.

And Can anyone confirm me whether it is the right approach or not?

and will variable values in the script will change automatically when period value changes .

1 Solution

Accepted Solutions
Highlighted
MVP & Luminary
MVP & Luminary

Re: Current Period and Previous Period in the script

Try these:

vPeriod = Date#(PERIODO,'YYYYMM')

vCurrentYear = Year($(vPeriod))

vCurrentMonth: Month($(vPeriod))

vPreviousYear: Year($(vPeriod))-1

vPreviousMonth: Month(MonthStart($(vPeriod),-1))

and will variable values in the script will change automatically when period value changes

Yes. if you calculate the variables in the script then they will be change during reload when the source data contains new data


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Highlighted
MVP & Luminary
MVP & Luminary

Re: Current Period and Previous Period in the script

Try these:

vPeriod = Date#(PERIODO,'YYYYMM')

vCurrentYear = Year($(vPeriod))

vCurrentMonth: Month($(vPeriod))

vPreviousYear: Year($(vPeriod))-1

vPreviousMonth: Month(MonthStart($(vPeriod),-1))

and will variable values in the script will change automatically when period value changes

Yes. if you calculate the variables in the script then they will be change during reload when the source data contains new data


talk is cheap, supply exceeds demand

View solution in original post

Re: Current Period and Previous Period in the script

Are you going call variables into Field ?? Where and what is not working for you?

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
gayatri7
Contributor II

Re: Current Period and Previous Period in the script

Thank you so much for your response!!!