Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Subtract/deselect end/max month

Hi

I have this simple code:

=if(sum({$}Month), LightRed(), lightgray())

The only thing I need is to say minus one Month, that is the last one. So if I choose "Jan, Feb and Mar", I need it too remove Mar. If I choose "Jun, Jul", I need it to only use Jun and so forth.  

21 Replies
Not applicable
Author

In this case  April to July are selected:

Unfortunately it looks like August is selected too. So far "=if(sum({$}Month), LightRed(), lightgray())" is used, and it almost work.  Do I really need an extra dataset to make it perfect?

Not applicable
Author

Ok, thx, see last post

Not applicable
Author

I am here btw:

richard_pearce6
Luminary Alumni
Luminary Alumni

Morning Mikael,

Apprecaite the images, after looking at those and making a few assumptions here is a simple example of what you originally requested.

Richard

Not applicable
Author

ah, thx for the effort

Unfortunately I only have the PE version, until I become skilled enough to get a job working with QV.

Could you plz post the code inside this blog?  

richard_pearce6
Luminary Alumni
Luminary Alumni

script:

 

// Lets assume this is your data


Original_Data:
Load * Inline [
Month ,Value
Jan ,10
Feb ,20
Mar ,30
Apr ,40
May ,60
Jun ,70
Jul ,80
Aug ,90
Sep ,100
Oct ,110
Nov ,120
Dec ,130
]
;


// The month is a sting and there are no other Date fields.
// First we need to convert the text into a number


Data:
NoConcatenate Load
Value
,
Month as Month_Original
,
Month(Date#(Month,'MMM')) as Month_Integer // This is a dual feild so it will read as text but treated as a number
Resident Original_Data;


Drop Table Original_Data;

richard_pearce6
Luminary Alumni
Luminary Alumni

Use Month_Interger as the chart dimension and the expression is

 

Sum

( {<Month_Integer={">$(=min(Month_Integer))<=$(=max(Month_Integer))"}>} Value)

richard_pearce6
Luminary Alumni
Luminary Alumni

A further expression can also be added:

 

Sum

( {<Month_Integer=>}Value)

Will give you the full year regardless of the selection made in Month_Integer. By promoting it higher than the first epression it will show behind and will give you the same effect as your image.

Richard

richard_pearce6
Luminary Alumni
Luminary Alumni

You don't have to drop your table. Just add the line transforming the text month into an integer.

I only dropped the table because this is an example.


Richard

Not applicable
Author

Sorry for a late response, but I just want to confirm that it works thx.