Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
manisha10
Contributor III
Contributor III

Display the highest difference and its corresponding values - Qlik Sense

Hi All, 

I have a table with Actual and Target Values. I want to display a table with max difference between Actual and Target along with the corresponding values in Col A and Col B.

ABActualTarget
CommercialUnsecured2011
ConsumerSecured1111
ConsumerUnsecured511
CommercialSecured411

 

Desired Output:

ABActualTarget
CommercialUnsecured2011

 

Thank you! 

Qlik Sense Business Qlik Sense Desktop  

2 Solutions

Accepted Solutions
Frank_Hartmann
Master II
Master II

Dimensions: A, B, Actual, Target

Expression: if(fabs(Actual-Target)=max(Total(fabs(Actual-Target))),fabs(Actual-Target),null())

and supress nullvalues for expression

View solution in original post

Frank_Hartmann
Master II
Master II

DimA =if(aggr(fabs(Actual-Target),A,B,Actual,Target)=max(Total aggr(fabs(Actual-Target),A,B,Actual,Target)),A,null())

DimB =if(aggr(fabs(Actual-Target),A,B,Actual,Target)=max(Total aggr(fabs(Actual-Target),A,B,Actual,Target)),B,null())

DimTarget =if(aggr(fabs(Actual-Target),A,B,Actual,Target)=max(Total aggr(fabs(Actual-Target),A,B,Actual,Target)),Target,null())

DimActual =if(aggr(fabs(Actual-Target),A,B,Actual,Target)=max(Total aggr(fabs(Actual-Target),A,B,Actual,Target)),Actual,null())

 

Expression =fabs(Actual-Target)

View solution in original post

6 Replies
Frank_Hartmann
Master II
Master II

You want the calculation in script or in frontend?

manisha10
Contributor III
Contributor III
Author

In frontend. 

Frank_Hartmann
Master II
Master II

Dimensions: A, B, Actual, Target

Expression: if(fabs(Actual-Target)=max(Total(fabs(Actual-Target))),fabs(Actual-Target),null())

and supress nullvalues for expression

manisha10
Contributor III
Contributor III
Author

Thanks a lot Frank! 😊 It is working on the above dataset. 

Now I'm searching how to suppress the rows with null values!  

MaxValue = if(fabs(Actual-Target)=max(Total(fabs(Actual-Target))),fabs(Actual-Target),null())

I have written these expressions to hide the rows with null values 

Dimension A: aggr(if(len([MaxValue])),A),A)

Dimension B: aggr(if(len([MaxValue])),B),B)

Dimension Actual: aggr(if(len([MaxValue])),Actual),Actual)

Dimension Target: aggr(if(len([MaxValue])),Target),Target)

But it is giving error.

 

Thank you!

 

 

Frank_Hartmann
Master II
Master II

DimA =if(aggr(fabs(Actual-Target),A,B,Actual,Target)=max(Total aggr(fabs(Actual-Target),A,B,Actual,Target)),A,null())

DimB =if(aggr(fabs(Actual-Target),A,B,Actual,Target)=max(Total aggr(fabs(Actual-Target),A,B,Actual,Target)),B,null())

DimTarget =if(aggr(fabs(Actual-Target),A,B,Actual,Target)=max(Total aggr(fabs(Actual-Target),A,B,Actual,Target)),Target,null())

DimActual =if(aggr(fabs(Actual-Target),A,B,Actual,Target)=max(Total aggr(fabs(Actual-Target),A,B,Actual,Target)),Actual,null())

 

Expression =fabs(Actual-Target)

manisha10
Contributor III
Contributor III
Author

Thanks a lot!! It is working 😊😊