# Qlik Sense App Development

Announcements
New Contributor

## Sum and Percentage Diff Between Two Max Dates Within Range

Hello Qlik Community,

In a nutshell I have 5 week ending dates as a dimension. From these 5 week ending dates (Friday) I want to select the latest 2 within the range and calculate the sum difference between them and also the percentage difference as two separate KPI's.

I've had a look online at other topics but I'm finding it difficult to apply the logic to my specific example.

Thanks for any help

2 Replies
Highlighted
Contributor II

## Re: Sum and Percentage Diff Between Two Max Dates Within Range

depending on how your data model looks, you should look into using FirstSortedValue to help identify the two dates that you need.

Alternatively you could create a rank variable, then reference the rank variable in set analysis to isolate each one.

New Contributor

## Re: Sum and Percentage Diff Between Two Max Dates Within Range

Hi Dan

Just an update on what I managed to do.

LET vLW = floor(now()-num(weekday(now())))-3;

LET vLWW = floor(now()-num(weekday(now())))-10;

LET vLWWW = floor(now()-num(weekday(now())))-17;

LET vLWWWW = floor(now()-num(weekday(now())))-24;