Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
alexpanjhc
Specialist
Specialist

how to get the max and min in a straight table

IDDaysmax(days)-min(days)-currentvalue
A50
B7-2
C23

Hi experts,

I have a straight table with ID and Days. ID is the dimension and Days is expression. i want to create the 3rd column as an expression but i do not know how to write the expression.

I want to find out the max number of days (7) and min number of days (2) in Days column and use that number  (5) minus the value in Days.

as the selections changes, the max number of days and min number of days will be changed  dynamically.

How do I achieve this?

thanks!

1 Solution

Accepted Solutions
sunny_talwar

Try this

RangeSum(Max(TOTAL Aggr(DaysExpressionHere, ID)), -Min(TOTAL Aggr(DaysExpressionHere, ID)), -Days)

Replace DaysExpressionHere with your Days expression

View solution in original post

10 Replies
sunny_talwar

May be this

RangeSum(Max(TOTAL Days), -Min(TOTAL Days), -Days)

alexpanjhc
Specialist
Specialist
Author

Thanks for replying, but it shows this

A     5     -5

B     7     -7

C    2      -2

looks like it is calculating only the line itself so max and min are the same.

sunny_talwar

I wonder why, I am seeing this

Capture.PNG

sunny_talwar

is Days a field or expression?

alexpanjhc
Specialist
Specialist
Author

Days is an expression.

sunny_talwar

Try this

RangeSum(Max(TOTAL Aggr(DaysExpressionHere, ID)), -Min(TOTAL Aggr(DaysExpressionHere, ID)), -Days)

Replace DaysExpressionHere with your Days expression

alexpanjhc
Specialist
Specialist
Author

Sunny, you are number 1!

thanks for your help!

sunny_talwar

No problem

alexpanjhc
Specialist
Specialist
Author

but i am wondering why can't I just use minus instead i have to use rangesum?