Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamic Set Analysis Expression

Hi guys,

I'm hoping you can help me with this. I'm building an application that allows the end user to specify a 'From' and To' date using the Input box object which then drives the period the transaction amounts need summing up. However the requirement is that it needs to only bring back the earliest transaction amount for a category within the user specified date range (From and To dates).

For example:

   

From15/01/2015= vMinTnxDate
To15/02/2015

= vMaxTnxDate

DimensionTnx DateAmount
A15/01/2015£10First Record
A16/01/2015£20
A17/01/2015£30
A18/01/2015£40
A19/01/2015£50
A20/01/2015£60
A21/01/2015£70Last Record
B18/01/2015£80First Record
B19/01/2015£90
B20/01/2015£100
B21/01/2015£110
B22/01/2015£120
B23/01/2015£130
B24/01/2015£140
B25/01/2015£150Last Record

My current expression in a Straight Table is:


Sum({<[Tnx Date] = {'>=$(vMinTnxDate) <=$(vMaxTnxDate)'}>} Amount)


This works so far as dynamically summing up the amount for each dimension within the date range. What I need the expression to do is take the records within the user date range and then just show the amount in the first record for each category (A & B) in this case £10 for category A and £70 for category B. and in a separate column show the latest amount for the respective categories.


I have come across this expression which works to an extent:


=Sum(TOTAL <Dimension>

           Aggr(

                    If([Tnx Date] = Min(TOTAL <Dimension> [Tnx Date]),Amount),

                    Dimension,[Tnx Date])

          )


Any help with this would be appreciated,


Many thanks

5 Replies
Anonymous
Not applicable
Author

I think the function FirstSortedValue() will help you.  Take a look.

maxgro
MVP
MVP

try with a str chart

Dimension

FirstSortedValue({<[Tnx Date] = {'>=$(vMinTnxDate) <=$(vMaxTnxDate)'}>} total <Dimension> Amount, -[Tnx Date])

FirstSortedValue({<[Tnx Date] = {'>=$(vMinTnxDate) <=$(vMaxTnxDate)'}>} total <Dimension> Amount, +[Tnx Date])



1.png

Not applicable
Author

Hi Michael,

many thanks for the quick response, I will try your proposed solution. With regards to efficiency, does the FirstSortedValue function cope well with high volumes i.e. when we hit the million mark transactions/records? just wondering what consideration I would need to take when it's scaled out.

Many thanks

maxgro
MVP
MVP

a million usually isn't a high volume

tries to mimic (makes some test data) the volumes that you will have in a few years

Not applicable
Author

Thanks Massimo

If I have to include more than one dimension, is it simple as adding it within the dimension list just after the TOTAL function.