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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rh203
Helper I
Helper I

Calculated Column: Sum of another column from same table based on criteria

Hi,

 

I am trying to sum a value in a table to create a pallet projection based on a starting stock position, inbound and outbound volume.

 

All of this data is within the same table but when I try to use a calculate function to bring back a value within the same table based on a couple of conditions, the formula simply brings back the total value from the column I am summing, rather than the specific sum of only the row criteria (product code).

 

Difficult to explain but the intention is to create a pallt projectio at product level which I can then roll up to various levels of aggregation.

 

To cut a long story short, it needs to be done like this in a calculated column format as the projection itself needs to be worked out in PBI itself during each refresh)

 

Thanks for any help

 

rh203_0-1601375700899.png

 

 

1 ACCEPTED SOLUTION

OK, you're on your way.

You could improve it by amalgamating the two FILTER clauses into one.

 

FILTER(Pallet_projection, Pallet_projection[dateke...] = 0  && Pallet_projection[factor...] = EARLIER Pallet_projection[factor...]

 

 

I've just shortened my typing with .......

View solution in original post

3 REPLIES 3
HotChilli
Super User
Super User

I think we'll need more information.

It's a little difficult to decipher the picture posted because all the scoring out and zero values.

 

Are you trying to get the sum of the 'Pallet Count Latest' value for all the rows that have the same Datekey Index and Factory Code as the current row?

Hi, Thanks for the reply - yes sorry I had to redact for obvious reasons.

 

I worked out the solution in the last 15 mins - see below.

 

Looks like 'EARLIER' is key to pick up the current row as the criteria for a filter within the CALCULATE function.

 

It's done the job.

 

Thanks for your help 

 

 

rh203_0-1601382766556.png

 

OK, you're on your way.

You could improve it by amalgamating the two FILTER clauses into one.

 

FILTER(Pallet_projection, Pallet_projection[dateke...] = 0  && Pallet_projection[factor...] = EARLIER Pallet_projection[factor...]

 

 

I've just shortened my typing with .......

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors