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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Johnrevheim
Frequent Visitor

accumulate by week and year

Hi,

I have a dataset where I want to calculate a running total of items orderes pr. week and compare it with

items ordered for the same week the year before. I need to see it sorted by the days in advanced the items

are ordered and year vs year. I cant seems to get it to work as it accumulates the numbers for both years. 

 

Anyone who could help?

image.PNG

 

 

 

1 ACCEPTED SOLUTION
v-huizhn-msft
Employee
Employee

Hi @Johnrevheim,

In your SPREADSHEET table, the Days before is missing out. While in your wanted result, the Days before values are continious?

Please add ALLEXCEPT function in filter of your formula. And create a matrix used to display what you want.

I try to reproduce, and I use your sample data table.

1.PNG

Create a measure using the formula.

RunningTotal = CALCULATE(SUM(SPREADSHEET[items]),FILTER(ALLEXCEPT(SPREADSHEET,SPREADSHEET[Year]),SPREADSHEET[Days before]>=MAX(SPREADSHEET[Days before])))

 

Finally, create a matrix, select the days before as Rows level, Year as Column level, please see the following screenshot.

2.PNG


If you have other issues, please feel free to ask.

Best Regards,
Angelia

 

View solution in original post

2 REPLIES 2
Johnrevheim
Frequent Visitor

Thank you very much. The days before is a running series in the original dataset. 

 

v-huizhn-msft
Employee
Employee

Hi @Johnrevheim,

In your SPREADSHEET table, the Days before is missing out. While in your wanted result, the Days before values are continious?

Please add ALLEXCEPT function in filter of your formula. And create a matrix used to display what you want.

I try to reproduce, and I use your sample data table.

1.PNG

Create a measure using the formula.

RunningTotal = CALCULATE(SUM(SPREADSHEET[items]),FILTER(ALLEXCEPT(SPREADSHEET,SPREADSHEET[Year]),SPREADSHEET[Days before]>=MAX(SPREADSHEET[Days before])))

 

Finally, create a matrix, select the days before as Rows level, Year as Column level, please see the following screenshot.

2.PNG


If you have other issues, please feel free to ask.

Best Regards,
Angelia

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.