4 Replies Latest reply: Mar 18, 2016 12:22 PM by Salvatore Strazzullo

# Difference of measure between two selected dates

Hi,

I have a table with 2 fields: a date  and a measure. I can select 2 date and I would like to have the difference between the two measure selected.

 Date Measure 1/1/2016 36 1/2/2016 44 1/3/2016 78 1/4/2016 32 1/5/2016 72 1/6/2016 96

If I select 1/1/2016 and 1/6/2016 I would have 96 - 36 = 60

I used the function Sum(Measure) - Below (Sum (Measure)) but it seem I can't order the result. What is the best way to calculate the difference of mesure between two date and order the result?

Thank you

Savio

• ###### Re: Difference of measure between two selected dates

Are you wanting to do this in a text box object?

For text box:

=FirstSortedValue(Measure, -Date) - FirstSortedValue(Measure, -Date, 2)

For straight table:

=Sum(Measure) - Above(Sum(Measure))

• ###### Re: Difference of measure between two selected dates

Sunny thank you for your time.

Maybe I had to add more informations, my ask was not complete. I am using Qlik Sense and I use the function Sum(Measure) - Below(Sum(Measure)) in a Bar Chart. I have two dimensions: Company and Date and  one measure = Sum(Measure) - Below(Sum(Measure)). The bar chart show me the Companies and the differences but I can't order them in the sorting parameters because I have two dimensions and the first is Company. I can't put the measure as first sort field. I can use other objects and functions, I would like to have the difference beetwen the two selected date ordered by Company with most first. I hope I had been more clear. Thank you. Savio

• ###### Re: Difference of measure between two selected dates

I would suggest that you add two list boxes to select dates

but you have to give the list boxes alternate states say State1 and State2

on your chart or text object you would write:

sum({State1}Measure) - sum({State2}Measure)

• ###### Re: Difference of measure between two selected dates

Hi thank you for your time.

I don't know I can use state in Qlik Sense.

Maybe I had to add more informations, my ask was not complete. I am using Qlik Sense and I use the function Sum(Measure) - Below(Sum(Measure)) in a Bar Chart. I have two dimensions: Company and Date and  one measure = Sum(Measure) - Below(Sum(Measure)). The bar chart show me the Companies and the differences but I can't order them in the sorting parameters because I have two dimensions and the first is Company. I can't put the measure as first sort field. I can use other objects and functions, I would like to have the difference beetwen the two selected date ordered by Company with most first. I hope I had been more clear. Thank you. Savio