Forum Discussion

RichardJ's avatar
RichardJ
Responsive Resident
5 years ago
Solved

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

3 Replies