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 September 15. Request your voucher.

Reply
guanel1
Helper I
Helper I

SUMX formula to filter on Measure that provides text - not working

I created a DAX as below that gives me the Current fiscal year - which is "FY2023". 

Current FY = MAX('Table 1'[FY])

This is a text field. 

 

I then want to filter the Billed Hours to only show the hours from this Fiscal Year. I created this DAX: 

Hours Billed = SUMX(FILTER('Table 1','Table 1'[FY]=[Current FY]),'Table 1'[Hours])

However, this is not working. It is not filtering out any of the hours. 

 

When I substitute the measure [Current FY] above with "FY2023" then it works.

Hours Billed = SUMX(FILTER('Table 1','Table 1'[FY]="FY2023"),'Table 1'[Hours])

This makes me think that the text is having issues - but the text that it is looking for comes from the same table so I'm not sure what is the issue.

I cannot just put "FY2023" in the formula because I need to keep the result dynamic over time. When new data is added, the hours billed sum updates to the new FY data. 

 

Thank you. 

1 ACCEPTED SOLUTION

@guanel1 
Please use 

Current FY = CALCULATE ( MAX ( 'Table 1'[FY] ), REMOVEFILTERS ( ) )

View solution in original post

10 REPLIES 10
tamerj1
Super User
Super User

Hi @guanel1 

Both [Current FY] and [Hours Billed] are measures right? How does your visual look like? Which columns / from which tables are involved?

Here is the example data to help explain my issue.  

guanel1_1-1677510432619.png

guanel1_2-1677510503808.png

Here are the measures i have created. 

guanel1_3-1677510538242.png

Here is what happens in PBI. I want to take the hours billed and forecast hours for the current year (this needs to stay dynamic so that this report can be used each year). 

The MEASURE NOT WORKING is where i tried to used the measures as listed above. The other table is where I replaced the measure [Current FY] with "FY2023" - and then it works. 

guanel1_5-1677511577296.png

 

@guanel1 
Please paste the same data as text (not screenshot).

I have found that adding the measure for [Current FY] works when I add it to the measure for table 2 but not for table 1. It seems like the data only works when you pull from a different table, but not when the data is from the same table...

 

Table 1 = Hours Billed

FYQtrProjectHours
FY20221A250
FY20222A500
FY20223A0
FY20224A0
FY20231A0
FY20232A300
FY20233A345
FY20234A525
FY20221B0
FY20222B150
FY20223B400
FY20224B75
FY20231B250
FY20232B0
FY20233B175
FY20234B350

 

Table 2 = Hours Forecasted

FYQtrProjectHours
FY20221A300
FY20222A300
FY20223A300
FY20224A300
FY20231A250
FY20232A500
FY20233A500
FY20234A1250
FY20221B0
FY20222B150
FY20223B150
FY20224B150
FY20231B150
FY20232B0
FY20233B250
FY20234B

250

 

Measures Created: 

Current FY = MAX('Table 1'[FY])

Hours Billed = SUMX(FILTER('Table 1', 'Table 1'[FY] = [Current FY]))

Hours Forecast = SUMX(FILTER('Table 2', 'Table 2'[FY] = [Current FY]))

So, looking at it more: 

I looks like the [Current FY] measure works only when it is coming from the OTHER table. 

The col "Hours Forecast" is correct when i use the [Current FY] in the measure. But when i try to use the [Current FY] that is coming from the same table, it doesnt work. 

 

How do i fix this issue? 

@guanel1 
Please use 

Current FY = CALCULATE ( MAX ( 'Table 1'[FY] ), REMOVEFILTERS ( ) )

@guanel1 
Have you tried this?

Yes, I tested it and it worked. Thank you!

Can you explain the logic behind adding the REMOVEFILTERS to the [Current FY] Measure? 

@guanel1 
It is context transition. In your measure:

Hours Billed = SUMX(FILTER('Table 1', 'Table 1'[FY] = [Current FY]))

Hours Forecast = SUMX(FILTER('Table 2', 'Table 2'[FY] = [Current FY]))

The measure [Current FY] is placed inside FILTER which is an iterator function. That would force context transition converting the Row context into a filter context. The screenshot below shows how both [Current FY] & [Current FY REMOVEFILTERS] measures are being evaluated inside FILTER. I hope once you can spot the difference, everything will become clear and you can can understand why you were getting those numbers.

1.png

 

Thankyou, i apreciate your help and explanations. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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