cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Anonymous
Not applicable

## Tricky - Sum Formula Based on the Month Column in Table

Hi Expert

I want to dynamically diagonally sum the values as shown in the image below based on the sample data. Tricky here is the diagonal must stop if Period 1 or Month 1 goes outside the range. In the image below Feb 20 is the last point (which corresponds to the Sept 19 in the smaller table) And input the results into the table on the right hand side..

Image

Sample PBIX

1 ACCEPTED SOLUTION
Community Support

Hi  @Anonymous,

First create a calendar table as below:

``calendar table = CALENDAR(MIN('Sample'[Month]),MAX('Sample'[Month]))``

Then create a relationship between calendar table and fact table.

Finally create a measure as below:

``````Measure =
VAR _6=CALCULATE(SUM('Sample'[6]),FILTER(ALL('Sample'),'Sample'[Month]=MAX('Sample'[Month])))
Return
_1+_2+_3+_4+_5+_6

``````

And you will see:

For the related .pbix file,pls see attached.

Best Regards,
Kelly

Community Support

Hi  @Anonymous,

First create a calendar table as below:

``calendar table = CALENDAR(MIN('Sample'[Month]),MAX('Sample'[Month]))``

Then create a relationship between calendar table and fact table.

Finally create a measure as below:

``````Measure =
VAR _6=CALCULATE(SUM('Sample'[6]),FILTER(ALL('Sample'),'Sample'[Month]=MAX('Sample'[Month])))
Return
_1+_2+_3+_4+_5+_6

``````

And you will see:

For the related .pbix file,pls see attached.

Best Regards,
Kelly

Announcements

#### Fabric certifications survey

Certification feedback opportunity for the community.

#### Power BI Monthly Update - April 2024

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

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors