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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
anmattos
Advocate I
Advocate I

Accumulated Measure using EARLIER and Inactive Relationship

Dear colleagueas,

 

I'm trying to make this measure work for the past couple of days, but it seems over my head. I tried many things explianed elsewhere about accumulated measures, but it seems my case is somewhat special. I think I got pretty near the solution, but can't get it.

 

I need a MEASURE to calculate the accumulated total of another measure, as in the tabel below:

 

anmattos_1-1632142154883.png

 

My current formula for "Total Accumulated" measure is:

=
CALCULATE (
    MAXX (
        fDCAs;
        COUNTROWS ( FILTER ( fDCAs; fDCAs[Rev] <= EARLIER ( fDCAs[Rev] ) ) )
    );
    USERELATIONSHIP ( dCalendar[Date]; fDCAs[Data Aprovação DCA] )
)

 

NOTE 1: I need a MEASURE, and not a CALCULATED COLUMN. This adds a bit of complexity when using EARLIER, since it needs a previous row context.

NOTE 2: The table has filters on the FILTER field and Slicers with DATES.
NOTE 3: For the TOTAL APPROVAL measure I have to use an inactive relationship between the CALENDAR table and the data table.

NOTE 4: I'm actually using PowerPivot.

 

The file XLSX file is available on the following link.

 

https://www.dropbox.com/scl/fi/tr2wuflc63jasjzw26kof/Accumulated-Calculation.xlsx?dl=0&rlkey=zj9g961...

 

Thank you very much for the help,

 

 

 

 

1 ACCEPTED SOLUTION

@anmattos Forgot the ALL

Total Approval =
  VAR __Rev = MAX('fDCA'[Rev])
  VAR __Table = 
    ADDCOLUMNS(
      DISTINCT(ALL('fDCA'[Rev])),
      "__TotalApprovals",[Total Approvals]
    )
RETURN
  SUMX(FILTER(__Table,[Rev]<=__Rev),[__TotalApprovals])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

@anmattos Try:

Total Approval =
  VAR __Rev = MAX('fDCA'[Rev])
  VAR __Table = 
    ADDCOLUMNS(
      DISTINCT('fDCA'[Rev]),
      "__TotalApprovals",[Total Approvals]
    )
RETURN
  SUMX(FILTER(__Table,[Rev]<=__Rev),[__TotalApprovals])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hello @Greg_Deckler ,

 

Thank you very much for the proposed solution. Unfortunately it returned the same results as my current formula.

 

Best regards,

@anmattos Forgot the ALL

Total Approval =
  VAR __Rev = MAX('fDCA'[Rev])
  VAR __Table = 
    ADDCOLUMNS(
      DISTINCT(ALL('fDCA'[Rev])),
      "__TotalApprovals",[Total Approvals]
    )
RETURN
  SUMX(FILTER(__Table,[Rev]<=__Rev),[__TotalApprovals])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Wow!!!

 

Thank you @Greg_Deckler ! It worked! Now I´ll need more 3 days to understand it, but the problem is solved.

 

Thank you very much for your time!

@anmattos Here's a walk-through:

Total Approval =
  VAR __Rev = MAX('fDCA'[Rev]) // Get the current value of Rev column in the current row
  VAR __Table = 
    ADDCOLUMNS(
      DISTINCT('fDCA'[Rev]), // Since we are in a visual where there is a single value of Rev in context, override this and get all the values of the distinct values of Rev in a single column table.
      "__TotalApprovals",[Total Approvals] // Add the measure to this single column table and the values returned are for the individual Rev values in the current virtual table row.
    )
RETURN
  SUMX(FILTER(__Table,[Rev]<=__Rev),[__TotalApprovals]) // SUM up the measure in our virtual table but filter the table such that only "previous" rows are summed.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.