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: 
thabo2g5
Contributor III
Contributor III

Creating a filter in frontend Qliksense

hi everyone 

I flagged some values based on this formula so i'm trying to create a filter so that user can filter  the flag , so i'm not sure of how do i create a filter from calculated value in frontend.

formula is  :  if(sum( [Unit Retail Price]-[PO Unit Cost])/sum( [Unit Retail Price]) <0.35 , ARGB(125,235, 51, 30),if(sum( [Unit Retail Price]-[PO Unit Cost])/sum( [Unit Retail Price]) >.65,argb(125,235, 51, 30)))

i just want to create a filter in front end when user click on it it show values filtered by formula above 

i've attached pic of flags below

thank you in advance.

 

 

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Because you are using an aggregation -- "Sum" --, you need to specify what field to aggregate (group) by.  In a chart, this is done by adding dimensions to the chart. In a filter, you must specify the dimension explicitly using Aggr(). 

For example, if we want a filter that puts Customers in two buckets, those with more than 500k in sales and those with less.

Aggr(if(Sum(Sales) > 500000, 'Over', 'Under'), Customer)

In your example it looks like you are setting the color when the calculation result is < 0.35 or > 0.65.  Let call the colored "Yes" and the others "No".   I'll assume your dimension is "Product".

Aggr(
if(sum( [Unit Retail Price]-[PO Unit Cost])/sum( [Unit Retail Price]) <0.35 
or if(sum( [Unit Retail Price]-[PO Unit Cost])/sum( [Unit Retail Price]) >0.65
, 'Yes', 'No')
, Product)

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

 

 

 

 

View solution in original post

2 Replies
melissapluke
Partner - Creator
Partner - Creator

Hi,

You should be able to put your formula into a filter. Here is an example:

I created a simple table with my "Audit ID". Within the table, I have a color expression.

melissapluke_0-1614963601618.png

melissapluke_1-1614963615092.png

I've then created a filter which mirrors my color expression, substituting the colors for a name of the filter option.

melissapluke_2-1614963683125.png

You are then able to use that filter to essentially filter by color.

melissapluke_3-1614963723944.png

 

 

 

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Because you are using an aggregation -- "Sum" --, you need to specify what field to aggregate (group) by.  In a chart, this is done by adding dimensions to the chart. In a filter, you must specify the dimension explicitly using Aggr(). 

For example, if we want a filter that puts Customers in two buckets, those with more than 500k in sales and those with less.

Aggr(if(Sum(Sales) > 500000, 'Over', 'Under'), Customer)

In your example it looks like you are setting the color when the calculation result is < 0.35 or > 0.65.  Let call the colored "Yes" and the others "No".   I'll assume your dimension is "Product".

Aggr(
if(sum( [Unit Retail Price]-[PO Unit Cost])/sum( [Unit Retail Price]) <0.35 
or if(sum( [Unit Retail Price]-[PO Unit Cost])/sum( [Unit Retail Price]) >0.65
, 'Yes', 'No')
, Product)

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com