0 Replies Latest reply: Nov 27, 2017 11:32 AM by Juan Moreno RSS

    FirstSortedValue based on two fields

    Juan Moreno

      Hi all,


      I have some records called "incidents" in my DB and I wanted to get the one with the longest duration. I did this and worked fine:


      FirstSortedValue({1<IsPlannedIncident={"0"},EventStatusId={"22"}>} TotalIncidentDuration,-TotalIncidentDuration, 1)


      Now I want to use another field called EventImapctId. I want to get the duration of the incident with highest impact, but this is returning a null:


      FirstSortedValue({1<IsPlannedIncident={"0"},EventStatusId={"22"}>} TotalIncidentDuration,-EventImpactId, 1)


      It's returning a null. Is it maybe because I many incidents with same impact and Qlik Sense doesn't know which one to choose? Is it possible to write the expression so in case of incidents with same impact it takes the one with longest duration?