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
Anonymous
Not applicable

Reference current row in a measure

Dear community,

 

I am more and more getting desparate with the following issue and therefore now turning to you. Until recently I was an Excel power user, but now turned towards PowerBi, which I am mostly very happy about.

 

The issue at hand is that I want to create a measure that uses the current row value as a reference. More specifically, I want to create a sum across a column for all rows which have a reference value (other column) >= the current row. I found out that this can be done in a "New Column" relatively easily. However, I need a measure as it should be processed further and must be adaptive to filtering in the report.

I attached an examplary table and a screenshot of how I would create that funtionality in Excel (in case it helps).Excel reference.PNG

ReferenceValues to sum upCumulative Sum
13.23051610712.24387441
10.88076764612.24387441
10.94091648612.24387441
10.30959866312.24387441
10.13756572212.24387441
20.9208494346.744509782
30.2929054475.823660349
30.2934943065.823660349
30.6191710525.823660349
30.4471428395.823660349
30.0354135095.823660349
30.026734835.823660349
40.5140890924.108798367
40.2978662414.108798367
40.6560811614.108798367
40.1638964064.108798367
50.5643059932.476865465
50.7964321832.476865465
60.2535677421.11612729
60.8625595481.11612729

 

Thanks so much in advance!

Steffen

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , try a new measure like

calculate(sum(Table[Values to sum]), filter(allselected(Table), Table[Values to sum] >=max(table[Values to sum])))

 

or new column like

sumx(filter(Table,Table[Values to sum] >=earlier(table[Values to sum])),[Values to sum])

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@amitchandak Thanks a lot!
The "measure"-version is what I was looking for. I replaced the columns within the filter bracket to the "Reference" column and that produces the desired result.

 

It still feels odd having to use the max() operator just to reference the current row, though. 

amitchandak
Super User
Super User

@Anonymous , try a new measure like

calculate(sum(Table[Values to sum]), filter(allselected(Table), Table[Values to sum] >=max(table[Values to sum])))

 

or new column like

sumx(filter(Table,Table[Values to sum] >=earlier(table[Values to sum])),[Values to sum])

 

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