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

Urgent AGGR HELP!!!

Hi All,

I am have problems with an AGGR SUM. Hopefully someone has an answer for me.

I have two records:

Supplier CodeDateAmount
00012012/01/015000
00012013/01/018000

What I need to do is roll up these two records into the latest record with a sum of the two amounts like this:

Supplier CodeDateAmount
00012013/01/0113000

How would I do it? I am using aggr(sum(amount),[supplier code]) the expression aswell as aggr(max(date),[supplier code] as a calculated dimension for the date. The result is two records, with the 13000 populated into the first record.

HELP!!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

So you are using Contracted as another dimension, right?

You need to define what you want to show for Contracted, when rolling up your two records into one. Maybe the status for the max date?

=FirstSortedValue(Contracted, -Date)

as expression (only using Supplier Code as dimension).

Besides this, one way to ignore dimensions in aggregations is using the TOTAL qualifier:

=sum(TOTAL<[Supplier Code]> Amount)

Hope this helps,

Stefan

View solution in original post

9 Replies
swuehl
MVP
MVP

Can you do your roll up in the script?

Something like

LOAD

     [Supplier Code],

     Date(max(Date)) as Date,

     sum(Amount) as SummedAmount

resident INPUT group by [Supplier Code];

drop table INPUT;

(or similar in a chart object).

Not applicable
Author

I cant do it in the script because the table I want to edit is a copy of an existing table for another client. I would need to do all the calculation within the object. Any ideas?

swuehl
MVP
MVP

[Supplier Code] as dimension, then two expressions:

=Date(max(Date))

=sum(Amount)

Not applicable
Author

If I do it that way I still get two records with their seperate amounts. I need the latest record with the total amount of the two records.

er_mohit
Master II
Master II

hi try this

SEE THE ATTACHED FILE ALSO

if(Date(Max(Date,'DD-MM-YYYY'))AND [Supplier Code],sum(Amount))

swuehl
MVP
MVP

Works for me, please check attached (also a calculated dimension using advanced aggregation is working).

I assume your data model or setting differs from what you posted above. Please check and adapt to my sample, then repost.

Not applicable
Author

The reason why it isnt working is because I have several other fields that are different on each record. For example, a supplier wasnt contracted but now they are contracted. I tested using only the three fields I mentioned and it works, but as soon as I pull the other fields in (contacted/non contracted), it splits to two records.

EG:

Supplier CodeDateContractedAmount
00012012/01/01NO5000
00012013/01/01YES8000

Is there any way to ignore the other fields when aggregating?

swuehl
MVP
MVP

So you are using Contracted as another dimension, right?

You need to define what you want to show for Contracted, when rolling up your two records into one. Maybe the status for the max date?

=FirstSortedValue(Contracted, -Date)

as expression (only using Supplier Code as dimension).

Besides this, one way to ignore dimensions in aggregations is using the TOTAL qualifier:

=sum(TOTAL<[Supplier Code]> Amount)

Hope this helps,

Stefan

Not applicable
Author

Thank you so much for your help Stefan. I used the FirstSortedValue function and kept Supplier Code as the only dimension and it worked perfectly!