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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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