Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
rm1
Contributor III
Contributor III

Create a formula dynamic on year

Hello everyone

I need to create a formula that should be dynamic on year filter, ignoring other selections.

I tried:  sum({1<year=p(year)>} sales) and it works. But there is an issue: if the year is not selected the result is obviously wrong.

What I'd like is: if year is not selected, give me the sales of current year. Otherwise give me the sales of selected year.

I tried with an if:  If (IsNull(year),  sum({1 <year=p({$(=year(today()))})>} sales),   .....etc etc)

But the part in red that replaces year=p(year) doesn't work. Does anyone can help me?

Labels (3)
2 Replies
kaushiknsolanki
MVP
MVP

Your expression should be

Sum({1<Year = {"$(=Max(Year))"}>}Sales)

 

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

Hi thanks.

I achieved the result through formula:  sum({$<year = {$(=year(today()))}>} [quantity activities]) --> this give me the total sales for 2020

using the formula you suggested it gaves me the quantity as if I'd use ALL:  Sum({1<Year = {"$(=Max(Year))"}>}Sales) results the same as Sum( all [quantity activities]) --> this give me the total sales for all years in my database.

Anyway your hint has been really helpful. thanks a lot!