Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
WEBINAR June 25, 2025: Build on Apache Iceberg with Qlik Open Lakehouse - REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
Seadon1210
Contributor II
Contributor II

Qlik Set Expression & Filtering

Hi,

Could someone kindly explain how the filter fields present in the following measure expression works in Qlik. 

Want to count the Quantity values for a dynamic date period, but I don't understand how finyear, finweek & CalendarMonth actually behave as the measure gives different calculated values when this measure is put in a combo chart visual with CalendarMonth on X axis and This measure on Y axis.

I have finyear, finweek, CalendarMonth and all such fields from Calendar table as filter/slicer in the qlik sheet.

vMax = max(weekstart (cal_date))

vMin = date(max(weekstart(cal_date) - (52*7)))

Year_Count =Count({<date={'>=$(vMin)<=$(vMax)'},[Quantity]={*}-{'0'},finweek=,finyear=,CalendarMonth=>}[Quantity])

8 Replies
Mark_Little
Luminary
Luminary

You are doing a count of the quantity field where it is not 0. Where the date is between the min and max variables, ignoring any selections on finweek, finyear, calendarMonth. 

You calendar is created by your dev so how they are defined you need to speak to them on how they are defined. 

Seadon1210
Contributor II
Contributor II
Author

Thanks @Mark_Little for your response. 

I just want to get a clear understanding of what does "ignoring any selection on finweek, finyear, CalendarMonth" mean actually. If I select any year from finyear slicer the visual bars of the measure show a change of bat length(i.e shows different count values). If the selection of the finyear should be ignored, why is the visual showing a change of measure output values?

agigliotti
Partner - Champion
Partner - Champion

Hi @Seadon1210 

I guess you need to add the same set analysis expression in  vMax  e  vMin variables as below:

vMax = max( {< finweek,finyear,CalendarMonth >} weekstart (cal_date))

vMin = date(max( {< finweek,finyear,CalendarMonth >}  weekstart(cal_date) - (52*7)))

 

I hope it can help.

Best Regards

Mark_Little
Luminary
Luminary

I would advise you read up on Set Analysis, how it is structured and how it is applied.

The part of set analysis within {<>} is called the set expression. This returns the set of data that your aggregation on (i.e. your count.)

With Qlik's associate engine your set analysis applied on top of any selections made with in your app. when you add something like finweek= and have a selection 2025 in finyear, you set analysis will still return values for all Finyears

Seadon1210
Contributor II
Contributor II
Author

Thanks @Mark_Little 

Set expressions is utilised to filter down full model dataset to a specific one needed. How set expression behaves with any slicer field selection was a doubt as it was not clearly available ito me n Qlik documentations I could find. Can you provide the appropriate resource where this is explained clearly?

Seadon1210
Contributor II
Contributor II
Author

Thanks @agigliotti for your response.

The variables aren't to be changed, they are suppose to behave as they are defined for. The output given by the Year_count measure is of concern as how the filters in the set expression of the measure would behave with the selection in slicer filters put outside in the sheet(calender fields present in measure are utilised as slicer along with other couple calender fields). The explanation of which I didn't find in any qlik resource, would appreciate if you could provide any.

Mark_Little
Luminary
Luminary

Take a look here 

https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/ChartFunctions/Se...

Also look at the free courses on Qlik learning.

If you want them to stay the full data set you use the 1 qualifier

Like

vMax = max( {< 1 >} weekstart (cal_date))

Once defines the whole set regardless of any selections

Mark

Seadon1210
Contributor II
Contributor II
Author

Thank you @Mark_Little for the help.