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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
felicia_nc
New Member

SUMX with multiple filters, does not include all dates

Hi! I am fairly new to DAX and I find it quite tricky.

 

I have a measure called [Amount Staging] that is (in a complex way) summing a column in my fact table: 'Booking'[Amount].

 

Generally, I use this measure together with two dimensions that the fact table has relationships to: 'Date' and 'Account'. I need to create a new measure that sums the [Amount Staging] results, and presents it on a certain account ('Account'[Account No]). There are two constraints for the new sum: it should only calculate the sum for [Account No]< 29000 and it should only include the selected year's entries and exclude the selected month's entries. So everything from the start of the year until (but not including) the start of the selected month.

This is how I contstructed the new measure:

 

VAR PriorForTheYear = 
CALCULATE (
       SUMX(
           VALUES('Account'[Account No]),
           [Amount Staging]
       ),
       FILTER (
           ALL ( 'Account' ),
           VALUE('Account'[Account No]) < 29000
       ),
       FILTER(
	  ALL('Date'), 
	  'Date'[Date] > EndOfLastYear && 'Date'[Date] <= EndOfLastMonth)
   )
 
VAR Result = IF( PLPriorForTheYearCheck, PriorForTheYear, [Amount Staging] )
RETURN RESULT

 

I have excluded the definition of some variables.


The issue: my result, when looking at the new measure together with 'Account'[Account No] and 'Date'[YearMonth], the new calculation sums correctly over the accounts, but only includes the [Amount Staging] for the previous month. At first I thought it was an issue with my date filter, and the EndOfLastYear in particular, but when I hardcoded it, I could see that I did get 0, when previous month was before the limit: It still did not sum all the previous months, until the lower limit.

 

Please let me know if you have an idea for what could be the solution here. I am currently thinking if it could be that I need to include "iteration" over 'Date', as it now possibly only iterates over the [Account No]?

 

*** UPDATE ***

I found a working solution: nested SUMX that iterates over Date[YearMonth] and further Account[Account No]

 

VAR PriorForTheYear = 
CALCULATE (

	SUMX(
		VALUES('Date'[YearMonth]),
      	 	SUMX(
           		VALUES('Account'[Account No]),
           		[Amount Staging]
       		)
	),
       FILTER (
           ALL ( 'Account' ),
           VALUE('Account'[Account No]) < 29000
       ),
       FILTER(
	  ALL('Date'), 
	  'Date'[Date] > EndOfLastYear && 'Date'[Date] <= EndOfLastMonth)
   )
 
VAR Result = IF( PLPriorForTheYearCheck, PriorForTheYear, [Amount Staging] )
RETURN Result
1 REPLY 1
Anonymous
Not applicable

Hi @felicia_nc ,

 

Awesome! Thank you so much for taking the time to share your solution!

 

Best regards,
Community Support Team_ Scott Chang

 

 

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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