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
alekos7
New Member

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 @alekos7 ,

 

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.

 

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
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.