Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

previous month filter date

Hello everyone,

I need to set an expression like this:

One is: if the user filter from aug 21º to sep 10º,

the other expresison needs to have the result of the same days but from the last month: jul 21º to aug 10º.

How could I do that?

e.g.

Diesel consumption:

from aug 21º to sep 10º = 21,2

set expression: jul 21º to aug 10º = 19,6

Tks

1 Solution

Accepted Solutions
Sergey_Shuklin
Specialist
Specialist

Hello, Samuel!

In set expression you can use Addmonths() function with Max() or Min() for indicating a range of output dates.

prev_mnt_selection.png

View solution in original post

4 Replies
Sergey_Shuklin
Specialist
Specialist

Hello, Samuel!

In set expression you can use Addmonths() function with Max() or Min() for indicating a range of output dates.

prev_mnt_selection.png

jonathandienst
Partner - Champion III
Partner - Champion III

Something along this pattern:

Sum{<Date = {">=$(vMinDate) <=$(vMaxDate)"}>} Amount)

Sum{<Date = {">=$(=AddMonths(vMinDate, -1)) <=$(=AddMonths(vMaxDate, -1))"}, Month, Year>} Amount)


Assumes that the min and max are defined in the correct date format, that the fact table date field is called Date. I have also added overrides so that the date selection does not interfere with the second expression. If this does not work you will need more information to give more specific help.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Anonymous
Not applicable
Author

Got it with this:

S_Date={'>=$(=addmonths(min(S_Date),-1))<=$(=addmonths(max(S_Date),-1))'}

Tks a lot,.

Anonymous
Not applicable
Author

Tks for attention Jonathan.

Got it worked.

Gonna create variables to be faster.