Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
deguza
Contributor II
Contributor II

What is wrong with this set ?

Hello all,

How do I fix the set expression below?

I am trying to restrict the x axis of counts of a field to three month.

The automatically generated expression with drag-and-drop is this:

= $(YearMonth)

I changed it to this:

= $ < YearMonth={'March 2022','April 2022','May 2022'}>

I get the following error:

"garbage after expression '='"

I also tried this:

= $(<YearMonth={'March 2022','April 2022','May 2022'}>)

The error now is

"Error in expression

= "

 

 

Thanks,

 

Deguza

 

 

Labels (1)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

There are two ways you can restrict data in your Chart

1) restrict calculation in measure

2) restrict dimension values

 

Ideally you should be restricting data using your measures

Example

Dimension = YearMonth

Measure1 = sum({<YearMonth={'March 2022','April 2022','May 2022'}>}Something)

 

 

IF restricting dimension values, you need to add a calculated dimension as below, in this case your dimension and measures will be as below

Dimension = AGGR(ONLY({<YearMonth={'March 2022','April 2022','May 2022'}>}YearMonth),YearMonth)

Measure1 = sum(Something)

 

You should also try to make in dynamic, to show last 3 months for example will be as below

=sum({<Datefield={">=$(=Date(Monthstart(Max(Datefield),-3)))<=$(=Date(Monthend(Max(Datefield),-1)))"}>}Sales)

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

2 Replies
vinieme12
Champion III
Champion III

There are two ways you can restrict data in your Chart

1) restrict calculation in measure

2) restrict dimension values

 

Ideally you should be restricting data using your measures

Example

Dimension = YearMonth

Measure1 = sum({<YearMonth={'March 2022','April 2022','May 2022'}>}Something)

 

 

IF restricting dimension values, you need to add a calculated dimension as below, in this case your dimension and measures will be as below

Dimension = AGGR(ONLY({<YearMonth={'March 2022','April 2022','May 2022'}>}YearMonth),YearMonth)

Measure1 = sum(Something)

 

You should also try to make in dynamic, to show last 3 months for example will be as below

=sum({<Datefield={">=$(=Date(Monthstart(Max(Datefield),-3)))<=$(=Date(Monthend(Max(Datefield),-1)))"}>}Sales)

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
deguza
Contributor II
Contributor II
Author

Thank you!

You also answered the next question I was about to post! I use the dynamic
date selection quite a bit in SQL and was wondering how one would do it in Qlik. Now I
know...