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

Set analysis for subtracting multiple date ranges.

Hi there,

There is a date range problem for me. I have selected multiple dates in the filter panel showing a table below:

  

Datesum(Cost)above(Date)
02/01/20185,745.0-
31/01/20183,829.002/01/2018
23/02/20181,875.031/01/2018
16/03/20182,392.023/02/2018
28/04/20182,870.016/03/2018
10/05/20187,734.428/04/2018
16/05/2018657.610/05/2018
01/06/2018531.716/05/2018
05/07/20188,245.201/06/2018
12/07/2018603.305/07/2018

Im tending to create a measure to subtract Gap form the selected Date and the previous selected date (ex: Cost in 12/07 - Cost 05/07,...) and the result is for the greater date as:

   

DateCostabove(Date)Gap
02/01/20185,745.0--1,916.0
31/01/20183,829.002/01/2018-1,954.0
23/02/20181,875.031/01/2018517.0
16/03/20182,392.023/02/2018478.0
28/04/20182,870.016/03/20184,864.4
10/05/20187,734.428/04/2018-7,076.8
16/05/2018657.610/05/2018-125.9
01/06/2018531.716/05/20187,713.5
05/07/20188,245.201/06/2018-7,641.9
12/07/2018603.305/07/2018-603.3

my set analysis is

sum({<Date=p(Date),>} Cost)

-

sum({<Date={"$=(above(Date))"}>} Cost)

but it didnot work.

Could anyone enlighten me!

Thanks in advanced. 

14 Replies
thi_pham
Creator III
Creator III

It's quite difficult to imagine what you are going to do.

If could, please provide a sample qvf with some samples of related fields.

For the dimension you want to add, if you have no idea how to make it on chart, I suggest to pre-specify it on data-load, then everything will become easier.

As you mentioned, you fixed a specific date to determine value of new dimension, I suggest to put the reference value to a fixed variable (by add equal character '=' before expression in variable).

Anonymous
Not applicable
Author

Im so sorry for not preparing example carefully. Let me explain again:

The Table of Customer:

DateCustIDCost
23/02A100
23/02A200
23/02B500
16/03C10
16/03A50
16/03B1000
28/04A500
28/04B200
28/04C100

For the status, im using the measure:

=if(aggr(sum({<Date={'28/04/2018'},>} Cost) -

     sum({<Date={'16/03/2018'}>} Cost),CustID)<0,'Less',More).

For Gap(1) is:

     sum({<backup_date={'28/04/2018'}>} Cost)

     -

     sum({<backup_date={'16/03/2018'},>} Cost)

Which can only show only 2 dates while i want some selected date to show the expected table above to check whether customer buy more or less following by the date:

 

DateCustIDSum CostGap(1)Status
23/02A300
16/03A50-250Less
28/04A500450More
23/02B500
16/03B1000500More
28/04B200-800Less
16/03C10
28/04C10090More

Then, I just want to minisize the table below only by date showing the amount for the final result :

 

DateGapStatus
23/02810
16/03-250Less
16/03500More
28/04-800Less
28/04540More

Using Below or Above like you can only show:

 

DateSum CostGap
23/02810
16/031060250
28/04800-260

The question is how i can create a measure that subtract from a punch of selected days.

Thank you a lot!

thi_pham
Creator III
Creator III

The idea is adding new column in data load to store the cost variance of each account comparing the previous day.

Hope it help.

Result.pngdataLoad.png

Anonymous
Not applicable
Author

You are once of a kind. However, i have to ask my manager to access into the data loader so i prefer something like function measure as set analysis for this situation.

Thank you again.

rangam_s
Creator II
Creator II

if(RangeSum(aggr(sum(Cost)-above(Sum(Cost),1),CustID))<0,'Less','More')

Try this, but it will not give you an expected results bcz Each Customer ID has different Status.