Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
shyamcharan
Creator III
Creator III

Getting Initial and Final values in a record

Hi Experts,

I have data as below

 

IDDisplay sequenceBP
14107
12108
13109
11110
26110
22120
23122
25

123

My requirement is to get the Initial and Final Blood Pressure readings as below:

 

IDBP InitialBP Final
1110107
2120110

Here the Display sequence is the number that tells the sequence of the reading and it does not always start at 1 in the data.

The result should find the minimum number in the display sequence against each ID and then get the BP value as BP Initial

The result should find the Maximum number in the display sequence against each ID and then get the BP value as BP Final


Thanks in advance


Regards,

Shyam


1 Solution

Accepted Solutions
sunny_talwar

You need this in the script? Try this

[BP monitoring]:

LOAD * INLINE [

    ID, BP, Display sequence

    1, 110, 1

    1, 108, 2

    1, 109, 3

    1, 107, 4

    2, 120, 2

    2, 122, 3

    2, 123, 5

    2, 110, 6

];

FinalTable:

LOAD ID,

  FirstSortedValue(BP, [Display sequence]) as [BP Initial],

  FirstSortedValue(BP, -[Display sequence]) as [BP Final]

Resident [BP monitoring]

Group By ID;

DROP Table [BP monitoring];

Capture.PNG

View solution in original post

5 Replies
sunny_talwar

You need this in the script? Try this

[BP monitoring]:

LOAD * INLINE [

    ID, BP, Display sequence

    1, 110, 1

    1, 108, 2

    1, 109, 3

    1, 107, 4

    2, 120, 2

    2, 122, 3

    2, 123, 5

    2, 110, 6

];

FinalTable:

LOAD ID,

  FirstSortedValue(BP, [Display sequence]) as [BP Initial],

  FirstSortedValue(BP, -[Display sequence]) as [BP Final]

Resident [BP monitoring]

Group By ID;

DROP Table [BP monitoring];

Capture.PNG

sunny_talwar

Or you can do this on the front using similar FirstSortedValue Functions

1) FirstSortedValue(BP, [Display sequence])

2) FirstSortedValue(BP, -[Display sequence])

Capture.PNG

shyamcharan
Creator III
Creator III
Author

Wow, thanks heaps Sunny.

I think I will go with the first suggested solution and do it in the Database to have a separate table as I would need the other readings too in the dashboard.

When I use the second solution, every time I open the document it is taking a lot of time to display the dashboard.

I believe this will delay the display of the dashboard on the Access point

Please advice if I am wrong.

Regards,

Shyam.

sunny_talwar

performing something is background is always faster than doing it on the front end. But if you plan to perform 15 different things or if you want a calculation to change based on selection, then doing it in the back end might not make sense. So I guess knowing the trade-offs you can decide doing one or the other.

shyamcharan
Creator III
Creator III
Author

I agree Thanks again.