Jump to content

How to Calculate Difference of Summed values from one column based off Category in another column.


Recommended Posts

Posted

I am trying to sum all values based on B and subtract from that total all values based on A. My graph I am looking for I want the Date in my x axis and the volume as my y axis.

 

 

 

 

Name

volume

Date

 

 

A

50

7/14/2020

 

 

B

100

7/14/2020

 

 

C

25

7/14/2020

 

 

A

40

7/15/2020

 

 

B

80

7/15/2020

 

 

C

20

7/15/2020

 

 

A

10

7/16/2020

 

 

B

50

7/16/2020

 

 

C

5

7/16/2020

Posted

I am currently using this in my custom expression and using my filters to filter out C. It seems a little sloppy so I was wondering if maybe someone has a better format.

 

Sum(If([Name]="B",[Volume],-[Volume]))

Posted

I suggest to pivot your data table. Please see the attached PNG file.

Then you can easily calculate 'B minus A' and the rolling sum of 'B minus A'.

Sum([b minus A]) OVER (AllPrevious([Date]))Use the rolling sum on your y-axis and Date on x-axis.

The resulting table will look like this:

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...