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
AlbertJan
Frequent Visitor

Cummulative sales figures

Hello,

 

I am building a sales dashboard using a table SalesInfoPivot with summarized salesfigures per week. I want to add an extra column with cummulative salesfigures for each week. Part of the table looks like this:

 

AlbertJan_1-1635509136009.png

 

Column CummulativeCount should show the sum of [CountThisYearPerWeek]-values for weeks from 1 until [Weeknumber]. In the example I would expect the values 110 - 257 - 434 - 599 - 757 etc.

 

I am using the following code:

 

CummulativeCount = CALCULATE(
SUM( SalesInfoPivot[CountThisYearPerWeek] ),
FILTER(SalesInfoPivot,
SalesInfoPivot[WeekNumber] <= [WeekNumber]))
 
Apparently the FILTER does not accept or recognize [WeekNumber] and does not filter the data at all.
 
Any suggustion how to resolve this issue? Thanks in advance!

 

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Try adding EARLIER in so that it knows you're referring to the earlier (original) row context rather than the row context from FILTER.

 

CummulativeCount =
CALCULATE (
    SUM ( SalesInfoPivot[CountThisYearPerWeek] ),
    FILTER (
        SalesInfoPivot,
        SalesInfoPivot[WeekNumber] <= EARLIER ( SalesInfoPivot[WeekNumber] )
    )
)

View solution in original post

4 REPLIES 4
AlexisOlson
Super User
Super User

Try adding EARLIER in so that it knows you're referring to the earlier (original) row context rather than the row context from FILTER.

 

CummulativeCount =
CALCULATE (
    SUM ( SalesInfoPivot[CountThisYearPerWeek] ),
    FILTER (
        SalesInfoPivot,
        SalesInfoPivot[WeekNumber] <= EARLIER ( SalesInfoPivot[WeekNumber] )
    )
)

Thank you, Alexis. You made my day!

amitchandak
Super User
Super User

@AlbertJan , Try

 

CummulativeCount = CALCULATE(
SUM( SalesInfoPivot[CountThisYearPerWeek] ),
FILTER(allselected(SalesInfoPivot),
SalesInfoPivot[WeekNumber] <= [WeekNumber]))

 

or

 

 

CummulativeCount = CALCULATE(
SUM( SalesInfoPivot[CountThisYearPerWeek] ),
FILTER(all(SalesInfoPivot),
SalesInfoPivot[WeekNumber] <= [WeekNumber]))

Thanks for yor reply. Unfortunately this does not solve the problems. Rows are not filtered.

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.