Francisco Romero
Francisco Romero

Reputation: 13189

How to insert a function in where clause on Qlik Sense?

I am trying to use a MAX function inside WHERE clause on Qlik Sense.

I have charged a calendar and I have to make the sum of a specific value filtering it by max month of the max year specified. If I do the following statement separately:

Max({<Year={"$(=max(Year))"}>}Month)

it shows me correctly the max month of each row.

Instead of this, if I try to use this filter to filter my value it shows me only null values. This is the expression that I am using by the moment:

Sum({<Month=Max({<Year={"$(=max(Year))"}>}Month)>}Import)

How can I filter by month of the last year specified?

Thanks in advance!

Upvotes: 0

Views: 1707

Answers (1)

Markus Wall
Markus Wall

Reputation: 121

There's two thing that needs to be added for your expression to work: The dollar expansion for the whole max expression and an outer expression for the year (unless you want to sum for all months x for all years, where x is the largest month of the latest year)

sum({< Month = {"$(=max({<Year = {"$(=max(Year))"}>} Month}"}, 
     Year = {"$(=max(Year))"} >} Import }

Upvotes: 1

Related Questions