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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Reisae
New Member

Aggregate measure subtotal by rank of relationship amount

I am looking to create a rolling sum of the below table.  For example, the new measure would be $390,170 for first row, then 834,590 for the second row. The measure should function and "re-rank" based on the relationship names within the view (filtered) 

Amount is a calculated measure performing average of a calculated column (rate * total amount) minus a single filtered relationship name as the base value. 

 

Reisae_0-1692644964420.png

 

 

 

 

2 REPLIES 2
v-yueyunzh-msft
Community Support
Community Support

Hi , @Reisae 

According to your description, you want to get the rolling of the [Amount] sort by the filtered [Relationship Name].

For your need , i recommand you to use the slicer to filter the [Relationship Name] so that we can use the ALLSELECTEED() function to get the filter .

Here are the steps you can refer to :
(1)This is my test data, i create a [Amount] measure to simulate your situation.

vyueyunzhmsft_0-1692754999249.png

(2)Then we can create a measure like this:

Rolling Measure = var _t =  ADDCOLUMNS( ALLSELECTED('Table'[Relationship Name]) , "Amount" , [Amount]     )
var  _t2 = ADDCOLUMNS(_t , "flag" ,RANK(DENSE,_t,ORDERBY([Amount],ASC,[Relationship Name],ASC))    )
var _cur_Name= VALUES('Table'[Relationship Name])
var _cur_falg =MAXX( FILTER(_t2 , [Relationship Name] in _cur_Name) , [flag])
return
SUMX(FILTER( _t2 ,[flag] <=  _cur_falg) , [Amount])

 

(3)Then we can put the fields we need on the visual and we can get the result as follows:

vyueyunzhmsft_1-1692755069527.png

 

And when we filter on the slicer , it will also work .

vyueyunzhmsft_2-1692755092200.png

 

 

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements