Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
leopatto
Contributor
Contributor

How can I calculate the difference in quantity between the oldest and most recent dates

I'm creating a dashboard and I inject my data via SQL that has 2 columns that are used in this case; 

 

Date | Quantity

01.01.2024 | 1

01.05.2024 | 9 

 

Now the difference is +8 but I don't know how to proceed with that. 

 

Max(Quantity) - Min(Quantity) -- i know it's something along these lines 😞 

Labels (1)
1 Reply
M_B
Contributor III
Contributor III

Try this:

If(Isnull(Above(quantity)), quantity, quantity - Above(quantity))

Something to consider is that your data should probably be sorted (It seems your data is sorted on date).

I tried this data:

load
date,
quantity
Inline
[date, quantity
01.01.2024 , 1
01.05.2024 , 9
01.10.2024 , 15
]

and got the following result:

date Sum(quantity) Sum difference
Totals 25 -
01.01.2024 1 1
01.05.2024 9 8
01.10.2024 15 6

 

Hope this helps.