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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Louveduval
Creator
Creator

How to make an measure without max(year)

Hello,

I'm trying to create a pivot table with my Sales, Sales Y-1, and Evolution. My dimensions are Product and Year, and I want to achieve this without modifying the script (otherwise, where's the fun in that?).

For Sales, I simply use SUM(Sales), which is correctly filtered by Product and Year—no problem there.
However, when I try to calculate Sales for Y-1, it's not the same level. I've tried using P(), MAX(total <Year> Year), and Only(), but nothing seems to work as expected.

Louveduval_0-1741604987632.png

 

Do you know how I can achieve this? :3

Thanks! 😊

Labels (3)
1 Solution

Accepted Solutions
brunobertels
Master
Master

Bonjour 

Alors dans ce cas essaye avec before : 

année N 

Sum(Sales) 

la colonne d'avant (N-1) 

before(sum(sales)) 

et before accepte un offset dans ces paramètres : 

before(sum(sales),2)

 

brunobertels_0-1741625058901.png

 

View solution in original post

9 Replies
brunobertels
Master
Master

Hi 

May be try this :

 

Current Year Sales

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

 

Previous Year Sales

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

 

Regards

 

marcus_sommer

Such things are possible with interrecord-functions like above/below/before/after which enable in general the access to each visible cell of the chart. But by complex views it's not mandatory trivial to set their second/third parameter and/or to embed them within (nested) range- and aggr-functions. Therefore keeping it as simple as possible could save many efforts.

Above - chart function | Qlik Cloud Help

Easier may be to remove the "restricting" dimension - here the Year - and to apply n expressions with a n appropriate reference to the wanted year like shown by @brunobertels.

Louveduval
Creator
Creator
Author

I don't want to use Max(Year) because that use the max or the min of my script and not the max or min from my column  

(pour les fan de rugby : le problème est que je veux avoir l'information grâce à la  colonne année du tableau croisée et pas avec l'année du script et  devoir faire beaucoup de mesures avec -2 pour comparer 2023/2024, -3 pour 2022/2023  etc ... par exemple)

brunobertels
Master
Master

Bonjour 

Alors dans ce cas essaye avec before : 

année N 

Sum(Sales) 

la colonne d'avant (N-1) 

before(sum(sales)) 

et before accepte un offset dans ces paramètres : 

before(sum(sales),2)

 

brunobertels_0-1741625058901.png

 

Louveduval
Creator
Creator
Author

je vais essayer ça demain 🙂 

Chanty4u
MVP
MVP

Try this 

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

 

Louveduval
Creator
Creator
Author

'only' work if I use an active selection  🙂 

Louveduval
Creator
Creator
Author

this solution is easy and work for me , thank you very much !!! 

brunobertels
Master
Master

Bonjour 

Bonne nouvelle, ravi d'avoir pu aider 🙂 

Bonne journée.