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

Set analysis with aggr fuction

Hello there,

I am struggling to get this set analysis right to get the previous compare date value against the current selected business date.

Please, find the below sample data and will appreciate your help and quick response.

Metric IDLBDBDCOMPARE_BDMetricValue
12014-08-232014-08-252014-08-20100
22014-08-242014-08-252014-08-21200
32014-08-252014-08-252014-08-22300
12014-08-262014-08-282014-08-231000
22014-08-272014-08-282014-08-241500
32014-08-282014-08-282014-08-25600

The out required as below for the selection BD = '2014-08-28'

Metric IDValueCompare BDPrevious Value
Total3100-600
110002014-08-23100
215002014-08-24200
36002014-08-25300

I am using set analysis with aggr function but it's not giving me the right value as it is showing the current values only

Compare BD = only(aggr(NODISTINCT only(COMPARE_BD),[Metric ID])) - which is working fine

Sum({<"LBD = {only(aggr(NODISTINCT only(COMPARE_BD),[Metric ID]))}" >} MetricValue)

Please, let me know if you required more information on requirement.

Thanks,

S

1 Solution

Accepted Solutions
Not applicable
Author

I think I have found the solution without using set analysis as below

sum({<BD=>}if(LBD=aggr(nodistinct only(COMPARE_LBD),[Metric Name]),[Metric Value]))

AS it seems to be working but if anyone can find set analysis solution for this than it will be great.

Thanks,

Sandip.

View solution in original post

5 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this in script

Data:

LOAD

*,

If(Previous(MetricID) = MetricID, Previous(MetricValue)) AS PreviousValue;

LOAD

*

FROM DataSource

ORDER BY MetricID, COMPARE_BD;

Now use PreviousValue in your set analysis.

Regards,

Jagan.

Not applicable
Author

Hi Jagan,

Thanks for your reply, appreciate it.

This is just sample data I provided here the actual data model and presentation requirement is different.

Unfortunately, I need to use this in pivot table and the database is big and those values are in different tables and don't want to perform unnecessary resident load and etc.

Thanks,

Sandip.

jagan
Luminary Alumni
Luminary Alumni

Hi,

It is difficult to handle in front end.  Can you attach sample file?

Regards,

Jagan.

Not applicable
Author

Hi Jagan,

I don't have sample file at the moment.

Thanks,

Sandip.

Not applicable
Author

I think I have found the solution without using set analysis as below

sum({<BD=>}if(LBD=aggr(nodistinct only(COMPARE_LBD),[Metric Name]),[Metric Value]))

AS it seems to be working but if anyone can find set analysis solution for this than it will be great.

Thanks,

Sandip.