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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
RichardJ
Responsive Resident
Responsive Resident

Need help with syntax - adding a filter when calculating a sum please

Hi,

This measure works as intended - it shows all costs for a specific program :

 

 

Total Costs Program1 = 

CALCULATE (
   SUM(DataTable[Cost])+0,
   FILTER ( ALL ( DataTable ), DataTable[Program]= "Program1" && DataTable[Mode] = "Internal" )
)

 

 

But i cannot work out the correct syntax to add the filter statement above into the measure below:

The measure currently returns costs for the previous year for all programs but I would like to apply the criteria shown to select the previous years costs for Program1 only.

 

 

Total Costs Program1 (For Previous Year) = 
CALCULATE(SUM(DataTable[Cost]),DATESYTD(ENDOFYEAR(DATEADD('Calendar'[Date],-1,YEAR)),"12,31"))

 

 

I'm assuming the 

 

FILTER ( ALL ( DataTable ), DataTable[Program]= "Program1" && DataTable[Mode] = "Internal" )

 

should be incorporated into the immediately after the SUM( in the 'Total Costs Program1 (For Previous Year)' measure but am struggling to get the correct syntax.


Thanks,
Richard

2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

@RichardJ You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

RichardJ
Responsive Resident
Responsive Resident

Turned out the solution was pretty simple in the end.

 

Total Costs Program1 = 

CALCULATE (
   SUM(DataTable[Cost])+0,
   FILTER ( ALL ( DataTable ), DataTable[Program]= "Program1" && DataTable[Mode] = "Internal" ),   
   PREVIOUSYEAR('Calendar'[Date])
)

 

View solution in original post

3 REPLIES 3
RichardJ
Responsive Resident
Responsive Resident

Turned out the solution was pretty simple in the end.

 

Total Costs Program1 = 

CALCULATE (
   SUM(DataTable[Cost])+0,
   FILTER ( ALL ( DataTable ), DataTable[Program]= "Program1" && DataTable[Mode] = "Internal" ),   
   PREVIOUSYEAR('Calendar'[Date])
)

 

Greg_Deckler
Community Champion
Community Champion

@RichardJ You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks for the assistance @Greg_Deckler . Thats Time Intelligence you provided were very helpful.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.