cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Anonymous
Not applicable

Limit running total by date

I have two datasets

 

Plans

PlanId | StartDate | Article | Required

1         | 01.01.22 |     a      |      5

1         | 02.01.22 |     a      |      10

1         | 02.01.22 |     b     |      5

 

Deliveries

DeliveryId | DeliveryDate | Article | RunningTotal

1               |   01.01.22      |      a     |    2

1               |   02.01.22      |      a     |    4

1               |   03.01.22      |      a     |    6

1               |   03.01.22      |      b     |    6

 

 

I would now like to create a Measure with this result

 

PlanId | StartDate | Article | Required  | DeliveredByStartDate

1         | 01.01.22 |     a      |      5          |         2

1         | 02.01.22 |     a      |      10        |         4

1         | 03.01.22 |     b     |      5           |         6

 

The DeliveredByStartDate should select all deliveries matching the plan by Article, where the DeliveryDate is <= StartDate and then get the Max of the RunningTotals.

 

I have connected the data sets with an m:n relationship on "Article" so this covers the filtering by article

 

Then I have been able to get the Max of the RunningTotal of the Deliveries:

DeliveredByStartDate = CALCULATE(MAX(Deliveries[RunningTotal]), /*WHAT FILTER GOES HERE?*/)
 
But I am missing a Filter to filter the Deliveries by those <= Plan StartDate

 

 

Can someone help me out?

1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try following measure:

DeliveredByStartDate = CALCULATE(MAX('Deliveries Table'[Running Toal]),FILTER('Deliveries Table','Deliveries Table'[DeliveryDate] <= MAX('Plan Table'[StartDate])))

 

Thwe result you want:

vyadongfmsft_0-1666776260478.png

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yadongf-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try following measure:

DeliveredByStartDate = CALCULATE(MAX('Deliveries Table'[Running Toal]),FILTER('Deliveries Table','Deliveries Table'[DeliveryDate] <= MAX('Plan Table'[StartDate])))

 

Thwe result you want:

vyadongfmsft_0-1666776260478.png

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

I have connected the data sets with an m:n relationship on "Article" so this covers the filtering by article

Your data model seems to be missing a calendar table.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors