Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

wanyunyang
Contributor

two KPIs with same filter

I have two KPIs, KPI1 is using year1, KPI2 is using year2. I'm trying to create a filter called year, which for KPI1 is year1, for KPI2 is year2. Is that possible?

Thanks for help.

1 Solution

Accepted Solutions
jwjackso
Contributor III

Re: two KPIs with same filter

I like to use the P() function.  In the example below,

KPI1 is calculated by =Sum({$<Year1=P(Year)>}Val)

and

KPI2 is calculated by Sum({$<Year2=P(Year)>}Amt)

PFunction.PNG

this is the data I used:

Data:

Load * Inline [

Year

2018

2017

2016

];

Data1:

Load * Inline [

D1,Year1,Val

A,2018,100

B,2017,200

];

Data2:

Load * Inline [

D2,Year2,Amt

C,2017,300

D,2016,400

];

2 Replies
jwjackso
Contributor III

Re: two KPIs with same filter

I like to use the P() function.  In the example below,

KPI1 is calculated by =Sum({$<Year1=P(Year)>}Val)

and

KPI2 is calculated by Sum({$<Year2=P(Year)>}Amt)

PFunction.PNG

this is the data I used:

Data:

Load * Inline [

Year

2018

2017

2016

];

Data1:

Load * Inline [

D1,Year1,Val

A,2018,100

B,2017,200

];

Data2:

Load * Inline [

D2,Year2,Amt

C,2017,300

D,2016,400

];

pawwy1415
Contributor II

Re: two KPIs with same filter

Hi,

Try with alternate states.

Please find the attached sample app here replace Date with Year.

Community Browser