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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Papillon
Frequent Visitor

Calculate area under curve

Hi erverybody,

I'm struggeling with calculating the area underneath a curve in a stacked area chart. The curve is not following a function (like Integral calculus). The curve has bumps and dents. Base for the curve is a mesaure (not a specific column). 
Does anybody has an idea how to calculate the area?  Even a methode providing a close-to-real-result would be appreciated.
Thanks a lot!
P.S.: My goal is to compare serveral curves/areas by one key-figure. The area seems to be the most reasonable one.

 

Area under curve.jpg

1 ACCEPTED SOLUTION
talespin
Solution Sage
Solution Sage

hi @Papillon 

 

Please see if this works for you. Just picking up hypothetical example.

 

I am using Trapezoid method to calculate ares under the curve, there is no unit. If you want to compare it to something, compare apples to apples, do not change dimension/measure when comparing to something.

 

I am using X-Axis(Age) - Y-Axis (SalesAmount).

 

Area Under Curve =
SUMX(
                VALUES(Customer[Age]),
                VAR _MinAge = CALCULATE(MIN(Customer[Age]), REMOVEFILTERS(Customer[Age]))
                VAR _MaxAge = CALCULATE(MAX(Customer[Age]), REMOVEFILTERS(Customer[Age]))
                VAR _SelectedAge = [Age]
                VAR _PreviousAge = CALCULATE(MAX(Customer[Age]), REMOVEFILTERS(Customer[Age]), Customer[Age] < _SelectedAge)
                VAR _SelectedY = CALCULATE([Sales Amount])
                VAR _PreviousY = CALCULATE([Sales Amount], REMOVEFILTERS(Customer[Age]), Customer[Age] = _PreviousAge)
                RETURN IF(_SelectedAge = _MinAge, 0, ((_PreviousY+_SelectedY)/2)*(_SelectedAge-_PreviousAge))
        )
 
talespin_0-1709891777727.png

 

View solution in original post

7 REPLIES 7
talespin
Solution Sage
Solution Sage

hi @Papillon 

 

Please see if this works for you. Just picking up hypothetical example.

 

I am using Trapezoid method to calculate ares under the curve, there is no unit. If you want to compare it to something, compare apples to apples, do not change dimension/measure when comparing to something.

 

I am using X-Axis(Age) - Y-Axis (SalesAmount).

 

Area Under Curve =
SUMX(
                VALUES(Customer[Age]),
                VAR _MinAge = CALCULATE(MIN(Customer[Age]), REMOVEFILTERS(Customer[Age]))
                VAR _MaxAge = CALCULATE(MAX(Customer[Age]), REMOVEFILTERS(Customer[Age]))
                VAR _SelectedAge = [Age]
                VAR _PreviousAge = CALCULATE(MAX(Customer[Age]), REMOVEFILTERS(Customer[Age]), Customer[Age] < _SelectedAge)
                VAR _SelectedY = CALCULATE([Sales Amount])
                VAR _PreviousY = CALCULATE([Sales Amount], REMOVEFILTERS(Customer[Age]), Customer[Age] = _PreviousAge)
                RETURN IF(_SelectedAge = _MinAge, 0, ((_PreviousY+_SelectedY)/2)*(_SelectedAge-_PreviousAge))
        )
 
talespin_0-1709891777727.png

 

It works realy great for me! Thank you so much. I now, can easily compare different complex behavoiurs by just two figures!!!

hi @Papillon 

 

You're welcome.

Wow! Great! I'm impressed how quick you had that! From scratch? From a first view it seems to be the solution.  I' ll check that out in detail by weekend. I'll come back to it! Thx so far....

talespin
Solution Sage
Solution Sage

hi @Papillon 

 

Please ignore, I am using Contoso, age and sales. will share my findings.

talespin
Solution Sage
Solution Sage

hi @Papillon 

 

Can you please share pbix file with mock up data.

Hi @talespin ,

Thx for quick reply!

Hmm..... Understand!
As you may imagine, I'm not able to provide 1:1. I will check if I can setup easily a meaningful mock up. I'll be back. Regards

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.