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

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

Reply
K-LED
Helper I
Helper I

Cumulative quantity

Hello,

 

I have to calculate the cumulative quantity by weeks number. I have created a custom column "Wee Nr" that return the week number from a column data.

 

I have tried with this formulas without success :

Cumulative quantity by Week = 
CALCULATE(
   SUM('Table'[Quantity]), 
   FILTER(
      ALL('Table'[Week Nr]), 
     'Table'[Week Nr] <= Max('Table'[Week Nr])
   )
)

 

Cumulative quantity by weeks = 
CALCULATE(
    SUM('Table'[Quantity]),
    FILTER(
        ALLSELECTED(Table.[Date]),
        WEEKNUM(Table.[Date], 2) <= MAX([Week Nr]) && 'Table'.[Date] <= MAX('Table'.[Date])
    )
)

 

Does anyone have an idea what's wrong with my formulas ?

 

Many thanks

4 REPLIES 4
nandukrishnavs
Super User
Super User

@K-LED 

 

Can you provide a sample table and expected output values.

 


Regards,
Nandu Krishna

@nandukrishnavs 

 

I've created this quick measure which return exactly what I need 

CALCULATE(
    SUM('Table'[Quantity]),
    FILTER(
        ALLSELECTED('Table'[Week Nr]),
        ISONORAFTER('Table'[Week Nr], MIN('Table'[Week Nr]), DESC)
    )
)

 

And the result is :

Capture.PNG

 

Actually the problem is when I start to use the filter "Week Nr" it doesn't work well and it displays me the total per week and not the cumulative.

 

Note: the "Week Nr" column is a whole number as type. How can I fix that ?

 

Thank you for your reply!

Anonymous
Not applicable

Here's how to properly deal with weeks.

https://www.sqlbi.com/articles/week-based-time-intelligence-in-dax/

Best
D

many thanks @Anonymous 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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