Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
SkitzN27
Creator
Creator

Set Analysis for 1 year less than today & 2 years greater than today

Hi guys,

I'm trying to move this calculation to Set-Analysis in Qlik Sense when doing a count of sales. Can anyone help me with this?

Count(sales) for year:

=If(
    [Quarter Year]>=yearstart(addyears(today(),-1))
and [Quarter Year]<=yearend(AddYears(today(),+2))
    ,[Quarter Year]
    ,null())

Considering today (2020), I'd like to display the count of sales for years- 2019, 2020, 2021 & 2022

Next year (2021), it should dynamically change to 2020, 2021,2022,2023

Thank you so much!

1 Solution

Accepted Solutions
Taoufiq_Zarra

@SkitzN27  like ?

Count({$<[Quarter Year]={">=$(=date(yearstart(addyears(today(),-1))))<=$(=date(yearend(AddYears(today(),+2))))"}>} sales)
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

2 Replies
Taoufiq_Zarra

@SkitzN27  like ?

Count({$<[Quarter Year]={">=$(=date(yearstart(addyears(today(),-1))))<=$(=date(yearend(AddYears(today(),+2))))"}>} sales)
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
SkitzN27
Creator
Creator
Author

@Taoufiq_Zarra   Thank you so much, that definitely guided me to the right direction.
Although, I just had to add the date format:

Sum({$<QTR_Year={">=$(=Date(YearStart(AddYears(today(),-1)),'YYYY'))<=$(=date(yearend(AddYears(today(),+2)),'YYYY'))"}>} Sales)