Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have the below information on one customer. Since I have so many database tables joined, I am avoiding to modify my sql script. Therefore, I needed help on writing an expression to pick minimum response where ActualDateTime is minimum.
ClientNumber | Template | ActualDateTime | Assessment | SurveyQuery | Response |
C0001 | Arrival | 2015-08-23 01:10:00.000 | 1 | SurveyStat | 2 |
C0001 | Arrival | 2015-08-23 01:10:00.000 | 1.01 | SurveyStat | 2 |
C0001 | Arrival | 2015-08-23 01:10:00.000 | 1.02 | SurveyStat | 3 |
C0001 | Departure | 2015-08-23 01:25:00.000 | 1 | SurveyStat | 2 |
C0001 | Departure | 2015-08-23 01:25:00.000 | 1.01 | SurveyStat | 2 |
C0001 | Departure | 2015-08-23 01:25:00.000 | 1.02 | SurveyStat | 3 |
Expected Result:
ClientNumber | ActualDateTime | SurveyQuery | Response |
C0001 | 2015-08-23 01:10:00.000 | SurveyStat | 2 |
What will be the right expression to get the expected result?
Thank you.
May be this:
Expression:
TimeStamp(Min({<SurveyQuery={'SurveyStat'}>}ActualDateTime))
FirstSortedValue(DISTINCT {<Assessment = {1}, SurveyQuery={'SurveyStat'}>}SurveyQuery, ActualDateTime)
FirstSortedValue(DISTINCT {<Assessment = {1}, SurveyQuery={'SurveyStat'}>}Response, ActualDateTime)
TimeStamp(Min({<SurveyQuery={'SurveyStat2'}>ActualDateTime))
FirstSortedValue(DISTINCT {<Assessment = {1}, SurveyQuery={'SurveyStat2'}>>}SurveyQuery, ActualDateTime)
FirstSortedValue(DISTINCT {<Assessment = {1}, SurveyQuery={'SurveyStat2'}>>}Response, ActualDateTime)
Use FirstSortedValue() function
May be like this
Straight table
Dimension
ClientNumber
Expressions
TimeStamp(Min(ActualDateTime))
FirstSortedValue(SurveyQuery, ActualDateTime)
FirstSortedValue(Response, ActualDateTime)
Hi,
try
Dimension :
ClientNumber
Aggr(MinString(ActualDateTime),ClientNumber) (Check 'Suppress when Null value')
SurveyQuery
Expression :
Min(Response)
Regards,
Antonio
@Sunny! TimeStamp(Min(ActualDateTime)) gives me the right value. However, FirstSortedValue(SurveyQuery, ActualDateTime) is still giving me blank. It might be something to do on how my tables are joined.
Vishal -
I guess you have three rows with the same TimeStamp, how did you decide to pick 2 here and which 2 (Row 1 or Row 2)?
@Antonio! Response does not have to be minimum. I need to pick any response based on the minimum ActualDateTime. Your logic though of adding the dimension field will be helpful.
@Sunny!
Good catch. I updated my original post. I added "Assessment" column. In my sql it only picks records where Assessment value is 1. When I added a listbox to see what ActualDateTime are available, I see 2015-08-23 01:10:00.000 and 2015-08-23 01:25:00.000. So TimeStamp(Min(ActualDateTime)) gives me 2015-08-23 01:10:00.000. However, FirstSortedValue(SurveyQuery, ActualDateTime) results blank.
Sorry.
Try this:
Dimension
ClientNumber
Expressions
TimeStamp(Min(ActualDateTime))
FirstSortedValue(DISTINCT {<Assessment = {1}>}SurveyQuery, ActualDateTime)
FirstSortedValue(DISTINCT {<Assessment = {1}>}Response, ActualDateTime)