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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Memorable Member
Memorable Member

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
Memorable Member
Memorable Member

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?

nandic
Memorable Member
Memorable Member

@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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors