Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
karthick_hoag
Contributor
Contributor

Error in an expression to get a value corresponding to the latest(max) date for each dimension value

hi,

I need your help and expertise to solve an issue in writing an expression.

Here is the data:

METRIC_NAMEEFF_DATEVALUE_01VALUE_01_DESC
Access - Wait Times - Urgent Care (Door to Provider)438913Average
Access - Wait Times - Urgent Care (Door to Provider)438913.4Average
Access - Wait Times - Urgent Care (Door to Provider)439770.1Average
Access - Wait Times - Urgent Care (Door to Provider)439770.4Average
Admin Expense438910Summation
Admin Expense4389164.34Summation
Admin Expense43891138.31Summation
Admin Expense43922-22469.94Summation
Admin Expense439220Summation
Admin Expense4392255Summation

 

Here is my requirement:

I need to get the Avg(VALUE_01) for a metric which has VALUE_01_DESC as Average for the latest Month. Similarly, I need to get the Sum(VALUE_01) for a metric which has VALUE_01_DESC as Summation for the latest Month.

I have a straight table with METRIC_NAME as the dimension and the below expression:

Expression:

=if(VALUE_01_DESC = 'Average',
Avg({<EFF_DATE={">=$(=Max(EFF_DATE))"}>}VALUE_01),

if(VALUE_01_DESC = 'Summation',Sum({<EFF_DATE={">=$(=Max(EFF_DATE))"}>}VALUE_01)
))

 

I am not getting the expected o/p. Below is what I am getting as a result in the straight table:

 
METRIC_NAMEExpression
Access - Wait Times - Urgent Care (Door to Provider)0.25
Admin Expense0
 

Expression is not working as expected. I am sensing that the search string within set analysis to find out the max(EFF_DATE) per each METRIC_NAME is not working properly. 

So, how to writ e the search string to get the max(EFF_DATE) corresponding to each dimension (METRIC_NAME) value?

I have to get the below table (Expected O/p):

METRIC_NAMEExpression
Access - Wait Times - Urgent Care (Door to Provider)0.25
Admin Expense-22414.94

 

Thanks,

Karthick S

Labels (1)
1 Solution

Accepted Solutions
jwjackso
Specialist III
Specialist III

The Max(EFF_DATE) is 43977, which is for an Average.

 

=if(VALUE_01_DESC = 'Average',
Avg({<EFF_DATE={">=$(=Max({1<VALUE_01_DESC={'Average'}>}EFF_DATE))"}>}VALUE_01),

if(VALUE_01_DESC = 'Summation',Sum({<EFF_DATE={">=$(=Max({1<VALUE_01_DESC={'Summation'}>}EFF_DATE))"}>}VALUE_01)
))

View solution in original post

2 Replies
jwjackso
Specialist III
Specialist III

The Max(EFF_DATE) is 43977, which is for an Average.

 

=if(VALUE_01_DESC = 'Average',
Avg({<EFF_DATE={">=$(=Max({1<VALUE_01_DESC={'Average'}>}EFF_DATE))"}>}VALUE_01),

if(VALUE_01_DESC = 'Summation',Sum({<EFF_DATE={">=$(=Max({1<VALUE_01_DESC={'Summation'}>}EFF_DATE))"}>}VALUE_01)
))

karthick_hoag
Contributor
Contributor
Author

Thanks Jwjackso. That worked.