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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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

3 REPLIES 3
MKPartner
Helper I
Helper I

Hello, 

 

I don't want to replicate the same topic so I'm writing here. 

 

I have modified a bit above DAX to be aligne with 12months or 36months data and generate trend. 

 

Unfortuantely, It's not working and target are different. Can some help me to clear up below DAX ? 

 

Score Target = 
VAR MaxDate =
    MAX ( 'DATE_DUP'[WC_Month] )
VAR MinDate =
    DATE ( YEAR ( MaxDate ), MONTH ( MaxDate ) - MAX (DATE_DUP[TotalMonths] ), DAY ( MaxDate ) )

RETURN
        CALCULATE (
                IF(
                    ISFILTERED('Master Corporation'[Corporation]),
                        MAX('Cust Satisfaction'[Target]),
                        0.9
                ),
                FILTER ( 'COQ Calendar', 'COQ Calendar'[WC_Month] > MinDate && 'COQ Calendar'[WC_Month] <= MaxDate )
            )

 

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors