Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
Partner
Partner

Variable as a Dimension

In Qlik Sense I am trying to create a variable, or even a master dimension, that checks to see if the date on the record is between to variable dates.  I have tried the following and it is giving me an Invalid dimension:

IF(FEFTCount=1 AND [Transaction Date]>=$(vDateFrom) AND [Transaction Date]<=$(vDateTo),ExceptVehFuelType)

The [Transaction Date] and two variable fields have the same date format.

Tags (2)
1 Solution

Accepted Solutions
Highlighted

Re: Variable as a Dimension

Alternatively, you can create the new variable like this

If(IsNull(GetFieldSelections([Transaction Month])) and IsNull(GetFieldSelections([Transaction Week])), Addmonths(Today(), -20), Min(TOTAL TranDateTime))

View solution in original post

9 Replies
Highlighted

Re: Variable as a Dimension

How do you define vDateFrom and vDateTo variables? Make sure they have equal in front of the variable definitation

Highlighted
Partner
Partner

Re: Variable as a Dimension

Doing that broke other visualizations.  Here is the definition:

IF(ISNULL(GetFieldSelections([Transaction Month])) AND ISNULL(GetFieldSelections([Transaction Week])),Date(Addmonths(Today(),-20),'MM/DD/YYYY'),DATE(MIN(TranDateTime)))

Highlighted

Re: Variable as a Dimension

May be create a new set of variable for this calculated dimension?

Highlighted

Re: Variable as a Dimension

Alternatively, you can create the new variable like this

If(IsNull(GetFieldSelections([Transaction Month])) and IsNull(GetFieldSelections([Transaction Week])), Addmonths(Today(), -20), Min(TOTAL TranDateTime))

View solution in original post

Highlighted
Partner
Partner

Re: Variable as a Dimension

So this variable sets a starting date for set analysis.  Why would I add TOTAL?

Highlighted

Re: Variable as a Dimension

A calculated dimension cannot have an aggregation (Like Min, Max, Sum, Avg) without TOTAL (one value across the whole dashboard) or without Aggr() (if you need multiple values based on a single dimension or multiple dimensions. In other words, when you have Min(Date) in your calculated dimension, it take it as null. But if you do Min(TOTAL Date) it gives you the Min date across the whole dashboard based on your selections. =Min(Date) does a similar thing where it evaluate to expression to a single value and then passes the value to the calculated dimension. So, now you don't have Min(Date) going into your calculated dimension, but the actual value (for instance 01/01/2018).

Does that make sense?

Highlighted
Partner
Partner

Re: Variable as a Dimension

Sort of but this variable is currently working in the set analysis I have.  I am not trying to put this variable into a table.

Highlighted

Re: Variable as a Dimension

All I am saying is to create a new variable with new expression. Don't make changes to a variable which is already working elsewhere . Not sure if this is something you cannot do or not want to do

Highlighted
Partner
Partner

Re: Variable as a Dimension

It worked after I tweaked some of the other data points, thanks!