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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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