Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
antoniodneto
Creator II
Creator II

Help with KPI expression

Hi guys, I'm trying to solve one expression but without sucess.

I have the following set analysis:

IF([DATABASE]='01/09/2019',
(((SUM([RISCO_CREDITO])
+((SUM([RISCO_FRN])*-1)*4.1644)),

IF([DATABASE]='01/08/2019',
(((SUM([RISCO_CREDITO])
+((SUM([RISCO_FRN])*-1)*4.1385)))

When I use this created variable vRISK on a bar chart it works perfect.

Now I'm trying to use it on a static KPI that needs to show me the value of MAX(DATE).

So I chaged the IF Statement to use  IF((MAX([DATABASE])='01/09/2019', but it doesn't work.

Could you help me guys?

13 Replies
sunny_talwar

Is this the expression you tried (make sure you have placed the parenthesis at the right places)

If(Max([DATABASE]) = '01/09/2019',
   ((Sum([RISCO_CREDITO]) + ((Sum([RISCO_FRN])*-1)*4.1644)),
If(Max([DATABASE]) = '01/08/2019',
   ((Sum([RISCO_CREDITO]) + ((Sum([RISCO_FRN])*-1)*4.1385))))
antoniodneto
Creator II
Creator II
Author

@sunny_talwar is returning me NULL in my KPI

sunny_talwar

Would you be able to share  a sample to show this?

antoniodneto
Creator II
Creator II
Author

@sunny_talwar I corrected, but my KPI is not respecting the max date. I mean the calc just works when I select one DATE, if not looks the calc sum all dates.

I cant share because I'm not able to export.

sunny_talwar

In a KPI object with no dimensions?

antoniodneto
Creator II
Creator II
Author

Yes, Into a KPI object that need to show always the value of MAX DATE, if I select any another month it should calc also.

sunny_talwar

I am not sure I follow your request... can you may be share some mocked up data and explain what exactly needs to be the output based on no selection and selection in different months?

antoniodneto
Creator II
Creator II
Author

I did it.

So on my KPI is returning the value for 01/09/2019 (my max date) correctly, for example when I select 01/08/2019 is not calc and returns NULL it should to show the value for 01/08/2019.

 

If(Max([DATABASE]) = '01/09/2019',
((Sum({<DATABASE]={"$(=MAX([DATABASE]))"}>}[RISCO_CREDITO])

,
If(Max([DATABASE]) = '01/08/2019',
((Sum({<[DATABASE]={"$(=MAX([DATABASE,2]))"}>}[RISCO_CREDITO])

sunny_talwar

How did this get added to the expression?

image.png

Max(DATABASE, 2) won't be 01/08/2019 when 01/08/2019 is selected? Max(DATABASE) will be 01/08/2019. And this is not even the expression I shared? If you are going to use an expression which is different from the one that is shared, how do you expect it to work?

Best,
Sunny