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

Control dimension values with variables

Hi guys,

I'm trying to control the contents of a dimension with two date fields (using SimpleFieldSelect date items). The two date fields are connected to vDate1 and vDate2 variables.

In my app I have a Date dimension. There is date for every day for the last 3 years. My data model looks like:

DataTable
Date
Customer
Product
Volume

I only wish to display Date values that match the following:

- date from Date1

- date from Date2

- date from Date2 + 7 days

- date from Date 2 + 14 days

Screen Shot 2018-11-07 at 20.31.28.png

In my initial attempt I use:

=If(Date = Date(vDate1) or Date = Date(vDate2), Date)

This works the first time, that I select a date, but subsequent changes to the Date1 item, does not update the table.

Is it even possible to manipulate a dimension this way or should I consider another approach?

Thanks!

2 Replies
lcontezini
Partner - Creator
Partner - Creator

You're probably using the "=" operator inside the variable expression.

1. Take the operator out of the variable expression

2. Call the variables like:

=If(Date = Date($(vDate1)) or Date = Date($(vDate2)), Date)

rasmusnielsen
Partner - Creator
Partner - Creator
Author

Thanks for your reply.

I tried it, but it did not make much of a difference. The dimension is still not updated when I select a different date.

I am using this approach now and it seems to do the job:

=Aggr(

  If(

    Date = Date(vDate1)

        or Date = Date(vDate2)

        or Date = Date(Num(vDate2)+7)

        or Date = Date(Num(vDate2)+14)

        or Date = Date(Num(vDate2)+21)

        or Date = Date(Num(vDate2)+28)

        , Only(Date)), Date)