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
Anonymous
Not applicable

DAX for Cumulative total grouped by week number

Hi there,

 

I'm seeking help on DAX for cumulative total. I 'm familiar of running total however little confused when Week number and year comes into play. 

 

My below approach to cumulative total might be wrong. Please feel free to suggest different way of achieving the cumulative total for the line chart. Kindly remember the YEAR (2021 year W1 should not get cumulative along with 2022 W1)

 

AJAJ_0-1678372025168.png

 

AJAJ_1-1678373550809.png

 

 

Data

 

   On of my thought is, once I get the below format, when I drag to my chart, I could use max of running total by the week since there are multiple rows for a weeknumber.
DateDataWeek NumberCumulative total by weeknumber and specific YEAR   
1/1/2022A13 For week number 1, there are 3 records for this specific YEAR.
1/2/2022B13 For week number 1, there are 3 records for this specific YEAR.
1/3/2022C13 For week number 1, there are 3 records for this specific YEAR.
1/9/2022D24 Week 2 = 1 record, so cumulative of week1 + week2 = 4
1/18/2022E35 Week 3 = 1 row, so cumulative total = 3 W1 rows + 1 w2 rows + 1 w3 rows = 5
1/25/2022F47 etc .. so on...  
1/26/2022G47   

 

Thanks

2 REPLIES 2
YukiK
Impactful Individual
Impactful Individual

Try a measure like this:

Cumulative Total =
CALCULATE (
SUM('Table'[YourMetric]),
FILTER (
ALL( 'Table'[Date] ),
'Table'[Date] <= MAX ( 'Table'[Date] )
)
)
Anonymous
Not applicable

Thank you @YukiK 

 

i'm afraid it did not work as expected. Need count(*) to group by Week number and Year.

 

AJAJ_0-1678377120350.png

 

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.