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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ahp-sig
Frequent Visitor

Cumulative Sum by Category , year and month with missing values in data

How do you show cumulative sums by year that shows category even if its missing values in the source data for a time period?

For example: in the data below Product C is missing amounts in Feb-2023. The DAX measures i have tried so far are all excluding C from Feb cumulative results completely.

 

Source Data:

DateProductAmount
1/1/2023A1
1/1/2023B2
1/1/2023C1
1/2/2023C4
2/1/2023A9
2/2/2023B3
3/1/2023A4
3/1/2023B4
3/2/2023C3
1/1/2024A1
1/1/2024B1
1/1/2024C1
1/2/2024A3
1/2/2024C1
1/3/2024B4
2/1/2024A2
2/2/2024C1
2/2/2024B3
3/1/2024A9
3/1/2024B4
3/2/2024C3

 

What i have tried so far:

 

 

Measure = SUMX(FILTER(ALL('Table'),
YEAR('Table'[Date])=YEAR(MAX('Table'[Date])) && 
MONTH('Table'[Date])<=MONTH(MAX('Table'[Date])) && 
'Table'[Product]=MAX('Table'[Product])),'Table'[Amount])

 

 

I have also tried it with a calendar table with the same results

 

 

Measure 2 = 
var varDate = SELECTEDVALUE(CalendarTable[Date])
var varProduct = SELECTEDVALUE('Table'[Product])
return
CALCULATE([SumAmount],CalendarTable[Date]<=varDate,'Table'[Product]=varProduct,VALUES(CalendarTable[Year]))

 

 

 

Result in each case does not show C in Feb-23:

ahpsig_1-1709848454678.png

 

ahpsig_0-1709848190546.png

 

Expected results:

ahpsig_2-1709848597608.png

 

PBIX file
https://drive.google.com/file/d/1n4QcTUZHKGKPurARPLTHczo4df5iybCG/view?usp=sharing

 

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

ThxAlot_0-1709913845904.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

8 REPLIES 8
ThxAlot
Super User
Super User

ThxAlot_0-1709913845904.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



ahp-sig
Frequent Visitor

This does not produce the desired results

Desired Result:

ahpsig_2-1709851183966.png

 

Actual result:

ahpsig_0-1709851148033.png

 

Your period name came from your date table ?

Period name is just FORMAT('Table'[Date],"mmm-yyyy"). See the pbix file https://drive.google.com/file/d/1n4QcTUZHKGKPurARPLTHczo4df5iybCG/view?usp=sharing

Ok here it is

 

I have changed 2 columns on your matrice :

I choose product from Table

I choose Yearmonth from your calendar Table

JamesFR06_0-1709852377875.png

MEASURE =
VAR Product =
SELECTEDVALUE ( 'Table'[Product] )
VAR SelDate =
SELECTEDVALUE ( CalendarTable[YearMonthnumber] ) //your table period name
//now searching from the last day for this period yyyymm
VAR Lastday =
MAXX (
FILTER ( CalendarTable, CalendarTable[YearMonthnumber] = SelDate ),
CalendarTable[Date]
)
VAR SelYear =
YEAR ( Lastday )
VAR result =
CALCULATE (
SUM ( 'Table'[Amount] ),
'Table'[Date] <= Lastday
&& 'Table'[Product] = Product
&& YEAR ( 'Table'[Date] ) = SelYear
)
RETURN
result

The result of your formula is not a cumulative sum. Its just a normal sum.

Hi,

 

You are right sorry !!

Just add all(table) at the end like this

MEASURE =
VAR Product =
SELECTEDVALUE ( 'Table'[Product] )
VAR SelDate =
SELECTEDVALUE ( CalendarTable[YearMonthnumber] ) //your table period name
//now searching from the last day for this period yyyymm
VAR Lastday =
MAXX (
FILTER ( CalendarTable, CalendarTable[YearMonthnumber] = SelDate ),
CalendarTable[Date]
)
VAR SelYear =
YEAR ( Lastday )
VAR result =
CALCULATE (
SUM ( 'Table'[Amount] ),
'Table'[Date] <= Lastday
&& 'Table'[Product] = Product
&& YEAR ( 'Table'[Date] ) = SelYear,

all('Table')


)
RETURN
result

JamesFR06
Resolver IV
Resolver IV

HI

 

Please fiond the measure :

JamesFR06_0-1709850676573.png

Cumul =
VAR Product =
SELECTEDVALUE ( 'Tot Prod'[Product] )
VAR SelDate =
SELECTEDVALUE ( 'Tot Prod'[Date] )
VAR SelYear =
YEAR ( SelDate )
RETURN
CALCULATE (
SUM ( 'Tot Prod'[Amount] ),
'Tot Prod'[Date] <= SelDate
&& 'Tot Prod'[Product] = Product
&& YEAR ( 'Tot Prod'[Date] ) = SelYear
)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.