Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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

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

  • 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])

     

2 Replies

  • 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])

     

  • Anonymous's avatar
    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.