17 Replies Latest reply: Jun 2, 2016 3:06 AM by Mindaugas Bacius

Cannot properly connect data. Set analysis issue

Hei

There are two tables.

First table:

AmountDateKey
1002016-01-301
2002016-02-281
3002016-03-312
502016-04-302

Second table:

KeyDate2Value
12016-03-3010
12016-03-3120
12016-04-0130
22016-03-3015
22016-03-3125
22016-04-0135

1. Pick up all Amount fields where Date <= 2016-03-31.
2. Find the Date2 = 2016-03-31 and connect Value to the First table.
3. Make aggregation Amount * Value.

I was struggling to accomplish this task by using Set analysis.

Thank you!

• Re: Cannot properly connect data. Set analysis issue
1. I am now thinking is it even possible to make it work with Set analysis?
2. Maybe the data structure have to be changed?
• Re: Cannot properly connect data. Set analysis issue

Hi Mindaugas,

Date and Date2 should not be associated?

In point 2 When you select 2016-03-31 in Date 2 you want all values for the key of first table only or the value for the key/date combination of the first table?

Maybe you need to combine the key and date in both tables and associate data by that composite key only.

Please let me know if this helps.
Kind regards,

• Re: Cannot properly connect data. Set analysis issue

Santiago Respane

1. The Date and Date2 shouldn't be connected.
2. The result:
AmountDateKeyValueAggr
1002016-01-301

20

2000
2002016-02-281204000
3002016-03-312257500
Total13500
• Re: Cannot properly connect data. Set analysis issue

=SUM({<Date={"<=\$(=date(var_date))"}>}Amount) * Only({<Date2={"\$(=date(var_date))"}>}Value)

• Re: Cannot properly connect data. Set analysis issue

what is expected output?

• Re: Cannot properly connect data. Set analysis issue

HI

I notice you have two date2 values of 31/03/2016 in table 2 one for key value 1 and the other for key value 2. Would it not be best to make a unique field from key and date in table 1 to associate to the same unique key made up from key and date2 in table 2 and then you should be able to calculate the correct sum of amount*value.

Kindest Regards

Brian

• Re: Cannot properly connect data. Set analysis issue

The result:

AmountDateKeyValueAggr
1002016-01-301

20

2000
2002016-02-281204000
3002016-03-312257500
Total13500
• Re: Cannot properly connect data. Set analysis issue

Hi Mindaugas:

See attached file plz.

Regards.

• Re: Cannot properly connect data. Set analysis issue

Sum of amount is correct:

SUM({< Date = {"<=\$(=date(var_date))"}>}Amount), but you can't show Date field.

Date2 value -> Max({<Date2 = {"<=\$(=date(var_date))"}, Key = P({<Date = {"<=\$(=date(var_date))"}>})>}Date2)

May be this??

Regards!

• Re: Cannot properly connect data. Set analysis issue

Still cannot get it right.

I have modified the expression to:

```=sum(Amount)/only({<Date = {"2016.03.31"}>} Value)
```

It do not calculate the Total value:

Total sum works while selecting the State:

How should I solve that?

• Re: Cannot properly connect data. Set analysis issue

can you try this

sum(Amount)/Sum({<Date = {"2016.03.31"}>} Total <State>Value)

• Re: Cannot properly connect data. Set analysis issue

Unfortunately:

• Re: Cannot properly connect data. Set analysis issue

change total mode from "Expression total" to "Sum of Rows"

• Re: Cannot properly connect data. Set analysis issue

or try this

sum(Amount)/only({<Date = {"2016.03.31"}>} Total <State>Value)

• Re: Cannot properly connect data. Set analysis issue

kushal chawda

You're good at this!