Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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)
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)
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...