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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
mr_oli
Helper I
Helper I

Adding value from previous week to next week

Hello!


I am looking for a way to add value from previous week to next week and so on with same Product ID and same Location ID


This is what I got:

ProductLocationWeekValue
1a123301
1a123311
1a123321
1a123331
1a12334

1

 

And this is what I want to have:

ProductLocationWeekValue
1a123301
1a123312
1a123323
1a123334
1a123345

 

 

 

 

2 ACCEPTED SOLUTIONS
nandic
Super User
Super User

Hi @mr_oli ,

 

Could you try this formula:

Cumulative Value =
CALCULATE(
     SUM(Sheet1[Value]),
     ALLEXCEPT(Sheet1,Sheet1[Product],Sheet1[Location]),
     Sheet1[Week]<=EARLIER(Sheet1[Week])
)
 
cumulative sales.PNG
 
Cheers,
Nemanja
 

View solution in original post

v-alq-msft
Community Support
Community Support

Hi, @mr_oli 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

 

f1.png

 

You may create a measure as below.

Result = 
CALCULATE(
        SUM('Table'[Value]),
        FILTER(
            ALL('Table'),
            'Table'[Product]=SELECTEDVALUE('Table'[Product])&&
            'Table'[Location]=SELECTEDVALUE('Table'[Location])&&
            'Table'[Week]<=SELECTEDVALUE('Table'[Week])
        )
)

 

Result:

f2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

6 REPLIES 6
v-alq-msft
Community Support
Community Support

Hi, @mr_oli 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

 

f1.png

 

You may create a measure as below.

Result = 
CALCULATE(
        SUM('Table'[Value]),
        FILTER(
            ALL('Table'),
            'Table'[Product]=SELECTEDVALUE('Table'[Product])&&
            'Table'[Location]=SELECTEDVALUE('Table'[Location])&&
            'Table'[Week]<=SELECTEDVALUE('Table'[Week])
        )
)

 

Result:

f2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

nandic
Super User
Super User

Hi @mr_oli ,

 

Could you try this formula:

Cumulative Value =
CALCULATE(
     SUM(Sheet1[Value]),
     ALLEXCEPT(Sheet1,Sheet1[Product],Sheet1[Location]),
     Sheet1[Week]<=EARLIER(Sheet1[Week])
)
 
cumulative sales.PNG
 
Cheers,
Nemanja
 

Thank you @nandic. Its working great.

 

But could you please explain me how exactly ALLEXCEPT is working?
@v-alq-msft used ALL instead of ALLEXCEPT which sound like completely opposite and but formula is giving the same result.

 

How is that possible?

@mr_oli , @v-alq-msft  created measure using All function - this function removes any active filters and then adds specified filters in expression. For example, if you would like that some filters do not impact on measure (ie: selected week), you add expression filter(table,all(table[week])).

On the other hand, i created calculated column using AllExcept function - this function is equal to group by.
If i specified 2 columns in allexcept function, it means, sum amount by these two columns, other columns are not important for this measure.
It is commonly used when needed some percentage.
Original Measure: sum(amount)
Monthly Measure: calculate(sum(amount),allexcept(date[month])
Percentage: divide ([original measure]/ [monthy measure]

Here is also a nice overview of All functions: https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.