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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
MKPartner
Helper I
Helper I

Dynamic Targets based on filters or no filters

Hello All, 

 

I have a case which is problematic for me. I have a valuse with target. Untill any filtere is not applied then I'd like to see a line with target 90% but If I will apply filter based on slicer or choosing something in the matrix, I'd like to see specific valuse for this line with target lince dedicated for this line. I'm trying to use below DAX code but it isn;t work: 

 

Scores Target = 
    VAR Plant_target = 0.9  
    VAR Corporate_target = MAX('Cust Satisfaction'[Target])

RETURN

    IF( FILTER('Cust Satisfaction'),Plant_target,Corporate_target)
1 ACCEPTED SOLUTION
123abc
Community Champion
Community Champion

It looks like you're trying to create a measure that dynamically sets the target value based on whether any filters are applied. The DAX code you provided is close, but there are some issues with the syntax. You can achieve this by using a combination of ISFILTERED and HASONEVALUE functions to determine if filters are applied and then select the appropriate target value. Here's the corrected DAX code:

 

Scores Target =

VAR Plant_target = 0.9

VAR Corporate_target = MAX('Cust Satisfaction'[Target])

VAR Filtered = ISFILTERED('Cust Satisfaction')

RETURN

IF (

Filtered,

IF (

HASONEVALUE('Cust Satisfaction'[YourFilterColumn]), -- Replace with your actual filter column

Corporate_target, -- Specific target when a filter is applied

BLANK() -- No specific target when multiple filter values are selected

), Plant_target -- Default target when no filters are applied )

 

Replace 'Cust Satisfaction'[YourFilterColumn] with the actual column you are using in your filter/slicer. This code checks if filters are applied. If filters are applied, it checks if only one filter value is selected; if so, it uses the corporate target; otherwise, it returns BLANK() (no specific target). If no filters are applied, it uses the plant target.

Make sure to adjust the column and table names to match your data model. This measure should dynamically change the target value based on the presence of filters and the selection of filter values.

View solution in original post

2 REPLIES 2
123abc
Community Champion
Community Champion

It looks like you're trying to create a measure that dynamically sets the target value based on whether any filters are applied. The DAX code you provided is close, but there are some issues with the syntax. You can achieve this by using a combination of ISFILTERED and HASONEVALUE functions to determine if filters are applied and then select the appropriate target value. Here's the corrected DAX code:

 

Scores Target =

VAR Plant_target = 0.9

VAR Corporate_target = MAX('Cust Satisfaction'[Target])

VAR Filtered = ISFILTERED('Cust Satisfaction')

RETURN

IF (

Filtered,

IF (

HASONEVALUE('Cust Satisfaction'[YourFilterColumn]), -- Replace with your actual filter column

Corporate_target, -- Specific target when a filter is applied

BLANK() -- No specific target when multiple filter values are selected

), Plant_target -- Default target when no filters are applied )

 

Replace 'Cust Satisfaction'[YourFilterColumn] with the actual column you are using in your filter/slicer. This code checks if filters are applied. If filters are applied, it checks if only one filter value is selected; if so, it uses the corporate target; otherwise, it returns BLANK() (no specific target). If no filters are applied, it uses the plant target.

Make sure to adjust the column and table names to match your data model. This measure should dynamically change the target value based on the presence of filters and the selection of filter values.

Thanks for quick respons. It's work. 

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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

Top Solution Authors