cancel
Showing results for 
Search instead for 
Did you mean: 

RunningSum() sorted by Classification()

Former Member

Hi folks,

I have got 4 cars (A, B, C and D) and I want to calculate the running sum sorted by descending Cost as in the column D. Unfortunately this is easy if the column Cost is sorted in the table but I need the table sorted only by the dimension as in the image:

I need this special RunningSum to know if the car is taking part in the 50% most expensive cars (Yes if the sorted running sum is lower or equal than the 50% ot the total running sum )

I hope my explanation and the image are enogh to be understood.

Thanks in advance,

Jonás

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Jonás,

try this :

create a dimension variable [cost_dim] = 0-[cost];

create a measure variable  [runningsumcost] = Previous(Self ) In ([cost_dim])+[cost],

Use [runningsumcost] in your Report.

Let me know if it worked for you.

Regards,

Rogerio

Former Member
0 Kudos

Awesome.

It worked for me creating [runningsumcost] as a detail of [cost_dim]

Thanks,

Jonás

Former Member
0 Kudos

It happens that before the dimension Car I have other two dimensions (Brand and Country) which makes breaks in the same table.

I am trying to modify [cost_dim] and [runningsumcost] to work properly with those dimensions but I am not succeding.

Could you show me how to modify the variables with those dimensions?

Thanks,

Jonás

Former Member
0 Kudos

Hi Jonás,

I´m strugling with it myself. Can you share a piece of your data (like you did in the picture) but as a txt or excel file, as well as a printscreen of how you expect your data to be?

Regards,

Rogerio

Former Member
0 Kudos

Hi Rogerio,

I have no data to share, in fact, this is a silly example of the real problem but you hit with the behaviour of the variables. However I can show how the table looks like with Brand and Country with breaks.

I need to classify the car D as in the first half (0 to 5.5) of the cars bought.

Thanks for all your support,

Jonás

Former Member
0 Kudos

Hi,

Can you please elaborate a little bit more ? Why is car D in the first half ?

Regards,

Rogerio

Former Member
0 Kudos

First, I would sort the Cost measure in descendant order so the first row has the most expensive car.

Second, I would calculate the running sum to get the contribution between several cars in descendant order.

Having the Cost total which is 11, I want to know the cars which have contributed in the total cost the first 50% from 0 to 5.5. In this small example the first car covers almost the 50% of the total cost so I will classify as "In the first 50%"

As I said before, without Brand and Country dimensions in the table, your variables work perfectly. But I need the table sorted by the car name and with breaks for Brand and Country.

For example, after adding Country, Previous(Self) is not calculated and the running sum is equal to the cost.

Thanks

Jonás

Former Member
0 Kudos

Hi,

try

RunningSum([cost]) In [cost_dim])


Regards,

Rogério

Former Member
0 Kudos

Beautiful.

As in the table I have got Brand and Country from another data provider, I finally added Brand and Country from the data provider which has Cost and after merging the dimensions the running sum appeared correctly.

Again, thanks very much for all your support

Jonás

Answers (1)

Answers (1)

former_member741439
Discoverer
0 Kudos

There is a similar requirement in my project, I want to apply running sum (measure) where measure should be sorted in descending order. I don't want to alter table structure and also measure consist of duplicate values.

Please help me for getting this. Thanks in Advance.