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: 
Samanehsorournejad

How to shorten the filter content

Hi Everyone,

I have a filter with Content Year_Month, previously it shows all of the available value for this Coulmn

but now my Customer want me to show just last Month and current Month.

Is there any person who could help me how I can show just current Month and previous Month in my Filter?

I had tried this one but it gives me error

 

if(zeitpunktverarbeitungYearMonth>=Max(zeitpunktverarbeitungYearMonth)-1,
zeitpunktverarbeitungYearMonth, null()
)

 

Thanks in advanced

Filter.PNG

 

Labels (2)
1 Solution

Accepted Solutions
jbhappysocks
Creator II
Creator II

Hi

Looks like your field zeitpunktverarbeitungYearMonth is not a date field as you have "letzte 30 Tage" as a value. So if you need to create this in the interface you have to do something like this where you define each possible value, you can't base it on a "x>Date" condition . 

=if(match(zeitpunktverarbeitungYearMonth,
year(today())&'-'&num(month(today()),'00'),
year(monthstart(today())-1)&'-'&num(month(monthstart(today())-1),'00'),
'letzte 30 Tage')
,zeitpunktverarbeitungYearMonth,
Null())

 

It will work, but will not look very good:

jbhappysocks_0-1672908904030.png

 

If you instead add something like this in your script:

 

NoConcatenate
PeriodSelect:
Load
year(today())&'-'&num(month(today()),'00') as zeitpunktverarbeitungYearMonth
AutoGenerate 1;

Concatenate (PeriodSelect)
Load
year(monthstart(today())-1)&'-'&num(month(monthstart(today())-1),'00') as zeitpunktverarbeitungYearMonth
AutoGenerate 1;

Concatenate (PeriodSelect)
Load
'letzte 30 Tage' as zeitpunktverarbeitungYearMonth
AutoGenerate 1;

left join (datetable)
Load
zeitpunktverarbeitungYearMonth,
zeitpunktverarbeitungYearMonth as "Period Selection"
Resident PeriodSelect; drop Table PeriodSelect;

You will get a new dimension you can use instead of zeitpunktverarbeitungYearMonth that will look better for the user:

jbhappysocks_2-1672909032964.png

 

 

View solution in original post

5 Replies
rui24
Creator
Creator

Hi anehsorournejad

I think you can create a Dimension that search for these 2 field, the current month and the last month.

And when you add these dimension to your field only appear the 2 field that your customer want.

deepanshuSh
Creator III
Creator III

Create a variable having previous month value, i.e 

vprevmonth= month(today())-1 or as depicted if any specific format is being used for the month value then use that, and use it first in a table value to check if the values are actually matching or not.Then use

if (monthfieldname>=vprevmonth, monthfieldname, null())

Most likely the error is due to the mismatch in the search string and the data. 

Also, while posting the doubt do provide the error facing and the correct dataset for getting better responses and results. 

 

Trial and error is the key to get unexpected results.
tkas
Partner - Contributor
Partner - Contributor

If( montnOfyourColumn=month (today()) or montnOfyourColumn=month (today()-30) , montnOfyourColumn=month)

Mark_Little
Luminary
Luminary

Hi,

I would approach this is script, Create a new dimension in your calendar which just populated with the Dates that are equal to this month or last month, then use this field front end,.

jbhappysocks
Creator II
Creator II

Hi

Looks like your field zeitpunktverarbeitungYearMonth is not a date field as you have "letzte 30 Tage" as a value. So if you need to create this in the interface you have to do something like this where you define each possible value, you can't base it on a "x>Date" condition . 

=if(match(zeitpunktverarbeitungYearMonth,
year(today())&'-'&num(month(today()),'00'),
year(monthstart(today())-1)&'-'&num(month(monthstart(today())-1),'00'),
'letzte 30 Tage')
,zeitpunktverarbeitungYearMonth,
Null())

 

It will work, but will not look very good:

jbhappysocks_0-1672908904030.png

 

If you instead add something like this in your script:

 

NoConcatenate
PeriodSelect:
Load
year(today())&'-'&num(month(today()),'00') as zeitpunktverarbeitungYearMonth
AutoGenerate 1;

Concatenate (PeriodSelect)
Load
year(monthstart(today())-1)&'-'&num(month(monthstart(today())-1),'00') as zeitpunktverarbeitungYearMonth
AutoGenerate 1;

Concatenate (PeriodSelect)
Load
'letzte 30 Tage' as zeitpunktverarbeitungYearMonth
AutoGenerate 1;

left join (datetable)
Load
zeitpunktverarbeitungYearMonth,
zeitpunktverarbeitungYearMonth as "Period Selection"
Resident PeriodSelect; drop Table PeriodSelect;

You will get a new dimension you can use instead of zeitpunktverarbeitungYearMonth that will look better for the user:

jbhappysocks_2-1672909032964.png