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

Max within set analysis

I have a pivot table with dimensions 'Wares', 'Year-Week' and two expressions:

Max(Date)


Sum({$<Date = {"$(=Max(Date))"}>} [Amount])




The first expression (for test aid) determines the date of last week day and was calculated correctly. The second expression is calculated correctly only for the latest week, for previous weeks it is always eqval zero.

I need to see Amount for every last day of the week.

What is wrong in second expression?

Best regards!





1 Solution

Accepted Solutions
mike_garcia
Luminary Alumni
Luminary Alumni

Hi,


The Max(Date) Function will result in only one value, hence the expression will give you the amount for that date only.

What you need to do is create an array of values that correspond to the last day of every week. There can be several ways to accomplish this, depending on the available fields you have in your data model.

If you don't have it already, I would suggest to have a field created with the function weekday() that will assign the name of the day for every date. Then, if you want to sum the amount of all, say, Friday's, you could have an expression like:

sum({$<DayName = {'Fri'}>} Amount)


Note: The names of every day will be assigned as defined on the SET DayNames sentence at the beginning of the script.

Hope this helps.

Mike.

Miguel García
Qlik Expert, Author and Trainer

View solution in original post

2 Replies
mike_garcia
Luminary Alumni
Luminary Alumni

Hi,


The Max(Date) Function will result in only one value, hence the expression will give you the amount for that date only.

What you need to do is create an array of values that correspond to the last day of every week. There can be several ways to accomplish this, depending on the available fields you have in your data model.

If you don't have it already, I would suggest to have a field created with the function weekday() that will assign the name of the day for every date. Then, if you want to sum the amount of all, say, Friday's, you could have an expression like:

sum({$<DayName = {'Fri'}>} Amount)


Note: The names of every day will be assigned as defined on the SET DayNames sentence at the beginning of the script.

Hope this helps.

Mike.

Miguel García
Qlik Expert, Author and Trainer
Not applicable
Author

A lot of thanks, Mike!

Your idea helped me to solve a problem. 🙂