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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Create Calculated Table with customized formula (Simpson's Rule)

Hello,

 

I want to apply Simpson's rule on a table and create a new table to store the values. From the picture below, I have a TABLE and I want a calculated Table. There are multiple values in Area column and I want to apply the formula on each value of Area (i.e Group By). The formula can be seen in the formula bar.

 

Any help on this will be appreciated.

 

Thanks,

Vivian.

 

simpsons rule.PNG

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Stachu  @Ashish_Mathur  Thanks for the solutions. But I found an easy way to solve this problem. All I did was used Pivot feature in the edit query to Convert Rows of column "Steps" as columns with values as the column "value" in it.

After doing this I got individual columns for each step, Table after pivoting looked like

 

Area | step 0.02 | step 0.01| step 0.005 |...........

A      |   0            |    0         |  0.6            |............

 

then I just applied the formula using the calculated column.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@Stachu  @Ashish_Mathur  Thanks for the solutions. But I found an easy way to solve this problem. All I did was used Pivot feature in the edit query to Convert Rows of column "Steps" as columns with values as the column "value" in it.

After doing this I got individual columns for each step, Table after pivoting looked like

 

Area | step 0.02 | step 0.01| step 0.005 |...........

A      |   0            |    0         |  0.6            |............

 

then I just applied the formula using the calculated column.

Ashish_Mathur
Super User
Super User

Hi,

For each Area, will the entries in the steps column have to be arranged in descending order (as i can observe in your example)?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

@Ashish_Mathur  Yes they should be arranged in descending order.

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Stachu
Community Champion
Community Champion

in your original table add these 2 columns:

NextStep = 
VAR __Area = 'Table'[Area]
VAR __Step = 'Table'[Steps]
RETURN
CALCULATE(MAX('Table'[Steps]), FILTER(ALL('Table'), 'Table'[Area] = __Area && 'Table'[Steps]<__Step))
NextValue = 
VAR __Area = 'Table'[Area]
VAR __Step = 'Table'[NextStep]
RETURN
CALCULATE(MAX('Table'[Value]),FILTER(ALL('Table'),'Table'[Area] = __Area && 'Table'[Steps]= __Step))

then create a new table like this

Table2 =
GROUPBY (
    'Table',
    'Table'[Area],
    "Val", SUMX (
        CURRENTGROUP (),
        0.5 * ( [Value] + [NextValue] ) * ( [Steps] - [NextStep] )
    )
)


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.