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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Lancelot
Frequent Visitor

Why my measure not being added as per instruction

Hi All

 

I have a measure that calculates YTD profit after tax. The measure wirks fine as per the card on the picture. 

 

I also created another measure that checks if a field is Retained Earnings, and if it is, to add the YTD profit to the existing value.

 

Lancelot_0-1677659134277.png

Unfortunately that is not working. However if I add the value manually or hardcode it, it does work. Am I missing anything?

1 REPLY 1
MAwwad
Super User
Super User

 

It's difficult to say exactly what's causing the issue without seeing the DAX formula for your second measure. However, it's possible that the issue is related to the filter context of the measure.

When you manually add the value, you are explicitly adding it to the filter context. However, if you're trying to add it using a DAX formula, it may not be included in the filter context correctly.

One way to try to fix this is by using the CALCULATE function to modify the filter context. Here's an example of how you might modify your formula to use CALCULATE:

 

 
YTD Profit Retained Earnings = IF( SELECTEDVALUE('Table'[Field]) = "Retained Earnings", CALCULATE( [YTD Profit After Tax], ALL('Table'), // Remove all filters except the ones explicitly specified 'Table'[Field] = "Retained Earnings" // Apply the filter for Retained Earnings ), BLANK() )
 
 

In the above example, replace 'Table'[Field] with the name of the column that contains the field information. The ALL function removes all filters from the table except for the ones explicitly specified, which allows the calculation to include the Retained Earnings filter.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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