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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Aggregate Subtraction Based on Rank

I'm trying to set up a column which incrementally subtracts demand from capacity based on rank (#1 rank will subtract demand from capacity, then #2 rank will subtract its demand from remaining capacity, etc.). I'm pulling all of the data together with an append query, so the capacity does not exist at the project (demand) level but at the group level. My ideal end state would be a matrix visual that shows the project (demand) and rank as rows and the groups (supply) as columns. The values would display the remaining capacity after accounting for demand in each respective row. Does anyone have experience setting up a measure like that?

 

In the example below, let's assume the following:

Group 1 starts with capacity of 200, Group 2 with capacity of 500 and group 3 with capacity of 1000

Each Project has a demand of 20 

Group capacity values independent of each other

**Its critical for the calculation to happen in rank order, as the demand will vary for each project

 

RankProject NameGroup 1Group 2Group 3
N/ACAPACITY2005001000
0Project 1180480980
1Project 3160460960
2Project 19140440940
2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Is this you want?

vchenwuzmsft_0-1663295401223.png

Please use two table , one contains rank, project name, demand, another one group and capactiy like the following

vchenwuzmsft_1-1663295605947.png

Then create measure via this code:

 

Measure = 
var _rank = MAX('Table'[rank])
var _demand = CALCULATE(SUM('Table'[demand]),FILTER(ALLSELECTED('Table'),[rank]<=_rank))
var _capacity = SUM(capacity[CAPACITY])
return
IF(HASONEVALUE('Table'[rank]),_capacity-_demand,_capacity)

 

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

 

Anonymous
Not applicable

Thanks very much! This is super close to what I'm trying to accomplish. One item I failed to mention is that there can be multiple units of demand per project. These units are tied to the groups.

 

Below is an example of how demand differs by project & group. How would you update the measure to account for this?

 

Project Namegrouprankdemand
Project 1Group1 120
Project 3Group2 230
Project 19Group330
Project 1Group1 150
Project 3Group2 2100
Project 19Group3 3300

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors