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

Condition to Display only last 4 month.

Hi,

I am trying to display only last 4 months.

so for thaat I have Canonical_Month in script, which contains all 2015 and 2016 months.

LOAD

    Date(CanonicalDate, 'MM-DD-YYYY') AS CanonicalDate,

Month(CanonicalDate) As Canonical_Month;

Now i need only last 4 months irrespective of year.


How could i do this? Any help is appreciated

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

You can use the Where condition to restrict your data.

After From or Resident statement you should use Where condition like below.

Load *

From XYZ

where CanonicalDate >= addmonths(today(),-4);

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

3 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

You can use the Where condition to restrict your data.

After From or Resident statement you should use Where condition like below.

Load *

From XYZ

where CanonicalDate >= addmonths(today(),-4);

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
berryandcherry6
Creator II
Creator II
Author

Hi,

Thanks for reply

If i need to apply this condition in front end of  Dimension. How could i restrict data in dimension instead of  in script using where condition.

Could that be done?

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

In front end you should use the set analysis.

Your expression will become.

Sum({<Date = {">=$(=Addmonths(Max(Date),-4))"}>}Sales)

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!