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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Waseem
Helper III
Helper III

Applying filter on a YTD function

Dear Community 

 

I have a measure to calculate YTD numbers as follows:

 

YTD-Rev-CoS = CALCULATE(SUM(Model'[Value]),DATESYTD('New Date'[Date]),ALLSELECTED('New Date'[Month]))
 
I have another field namely Cost Type with two values as "Revenue" and "CoS". I am trying to apply a filter on the above function to filter for "Revenue" only using following formula:
 
SUMX(FILTER('Model',[Cost Type]="Revenue"),[YTD-Rev-CoS])
 
However I always get an incorrect number. Can someone please help as to if i am missing something?
 
Regards 
1 ACCEPTED SOLUTION
rohit1991
Super User
Super User

Hi @Waseem ,

You're close in your approach, but the issue lies in how the filter is being applied within your DAX expression. Your original YTD measure [YTD-Rev-CoS] already performs a CALCULATE operation, and then you're wrapping that in a SUMX over a filtered table, which can lead to context issues and incorrect results. Instead, you should apply the filter directly within the CALCULATE function that defines the YTD measure. For example, revise the measure like this:
YTD-Revenue = CALCULATE(SUM('Model'[Value]), DATESYTD('New Date'[Date]), 'Model'[Cost Type] = "Revenue", ALLSELECTED('New Date'[Month])).


This ensures that the "Revenue" filter is applied at the same level as the time intelligence logic, maintaining proper context and yielding correct results. Wrapping an existing measure in a FILTER function post-calculation can sometimes break the intended evaluation context, especially with time functions like DATESYTD.

 

Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

View solution in original post

2 REPLIES 2
rohit1991
Super User
Super User

Hi @Waseem ,

You're close in your approach, but the issue lies in how the filter is being applied within your DAX expression. Your original YTD measure [YTD-Rev-CoS] already performs a CALCULATE operation, and then you're wrapping that in a SUMX over a filtered table, which can lead to context issues and incorrect results. Instead, you should apply the filter directly within the CALCULATE function that defines the YTD measure. For example, revise the measure like this:
YTD-Revenue = CALCULATE(SUM('Model'[Value]), DATESYTD('New Date'[Date]), 'Model'[Cost Type] = "Revenue", ALLSELECTED('New Date'[Month])).


This ensures that the "Revenue" filter is applied at the same level as the time intelligence logic, maintaining proper context and yielding correct results. Wrapping an existing measure in a FILTER function post-calculation can sometimes break the intended evaluation context, especially with time functions like DATESYTD.

 

Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

@rohit1991  many thanks. Its clear and resolved my issues as well. All Kudus to you man

 

Regards 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.