Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Contributor II

calculated dimension in script

is it possible to create calculated dimension in Load script ? here is the expression I'm trying to use but its not working

Load MonthYear,

Addmonths(MonthYear,-Getselectedcount(MonthYear)) as PreviousSelection

resident CHC

5 Replies

Re: calculated dimension in script

The expression you have used is not possible, but what exactly are you trying to do? May be there are alternatives

Contributor II

Re: calculated dimension in script

I have to find sum sales of previous  # of months.

for example if user selected Jan-Feb sum(sales) is gonna give sales for current selection.

with below expression 

Addmonths(MonthYear,-Getselectedcount(MonthYear))  I can go back three months i.e( Oct-Dec) .

how do I write expression to find sale for OCT-DEC

Re: calculated dimension in script

Did you look at my response here?

Logic help


Re: calculated dimension in script

Please try to avoid creating multiple threads coping with more or less the same topic (I've counted four).

It just makes it hard to follow a discussion and clutters the forum.

Instead, please try to give feedback to the support offered and clarify any open questions.

If you want to use the selected count in your addmonths() function, I think you would need to use something like

Addmonths(MonthYear,-$(=Getselectedcount(MonthYear)) )

or create a variable that hold the selected count and use the variable.

So, just modifying what Sunny suggested in one of the other threads:

If(Sum(Sales)/Sum({<Date = {"$(='>=' & Date(AddMonths(Min(Date), -$(=Getselectedcount(MonthYear))), 'DateFieldFormatHere') & '<=' &Date(AddMonths(Max(Date), -$(=Getselectedcount(MonthYear))), 'DateFieldFormatHere'))"}, Month, Year, Week, MonthYear>}Sales) > 1, 'Sales Increased', 'Sales Decreased')

This should be used in a front end expression, not in your load script.

If this does not work out of the box (which it probably won't), it would be most easy to help you if you create a small sample QVW and attach it to this thread.



Logic help

Valued Contributor III

Re: calculated dimension in script

Hi arausanah,

You can't use GetSelectedCount on script. This may be calculated on line.