Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Qliklosophy
Partner - Contributor
Partner - Contributor

Measure as a filter

Hi All,

I am having some trouble with creating a measure as a filter in qlik  and I have already tried to search many other related threads, but was unable to find a similar problem.

My data looks as follows:

YearCustomerProductPrice
20001100010
20011200011
20021100012
20031300013
20002100014
20012200015
20022100016
20032300017

 

What I am trying to do, is make a filter so that you only see the products which have a higher average price for customer 1 compared to the maximum price of customer 2, whilst it still can be affected by year.  In the table I can make a new column with an if statement which puts a "YES" behind every product where the avg price for customer 1 is higher than the max price of customer 2 and otherwise a "NO" (whilst it is still affected by year). This column is quite usefull, but what I really want is to be able to filter this.

Anyone maybe have a solution for this?

1 Solution

Accepted Solutions
marcus_sommer

You may try something like this as starting point for the creation of a calculated dimension:

pick(rangesum(-(aggr(avg({< Customer -= {'Customer2'}>} Price) > max({< Customer = {'Customer2'}>} Price), Year, Customer)), 1), 'No', 'Yes')

With the real data it might be not so simple - if Price isn' just a field else an own calculation and if the comparing should happens within a different dimensionality - both would require further aggr() or maybe TOTAL on the inside respectively the outside - and if there are further fields/selections are included (probably it should work with selections and not with hard-coded customers).

If it's more than nice to have and you want to try to develop such logic - do it step by step slicing each expression part and merging them only to bigger calculations if the lower parts result in the expected values.

- Marcus

 

View solution in original post

1 Reply
marcus_sommer

You may try something like this as starting point for the creation of a calculated dimension:

pick(rangesum(-(aggr(avg({< Customer -= {'Customer2'}>} Price) > max({< Customer = {'Customer2'}>} Price), Year, Customer)), 1), 'No', 'Yes')

With the real data it might be not so simple - if Price isn' just a field else an own calculation and if the comparing should happens within a different dimensionality - both would require further aggr() or maybe TOTAL on the inside respectively the outside - and if there are further fields/selections are included (probably it should work with selections and not with hard-coded customers).

If it's more than nice to have and you want to try to develop such logic - do it step by step slicing each expression part and merging them only to bigger calculations if the lower parts result in the expected values.

- Marcus