Forum Discussion

Julier's avatar
Julier
Helper III
8 months ago
Solved

DAX MEASURE TO FILTER

I have this measure to show a machine target for each site, the conversion machine is the same name at both sites but the target differs by each site so i want the slicer to change the visual and sho...
  • Jaywant-Thorat's avatar
    Jaywant-Thorat
    8 months ago

    Hi Julier 

    Nice, good progress. i have gone thru all the posts. Two things are happening here:

    1. Your 'SelectedSite' calculation is more complicated than it needs to be and may return unexpected results (or blank) when more than one site is in context.

    2. If the site variable is blank or different text (case/space), the 'SWITCH' returns 'BLANK( )' and the chart shows no target. Also check that your target measures are numeric (they usually are — but if they return 'BLANK( )' because of filter context that will look like “not seeing” the number).

    If you created a separate 'Site' table and your slicer uses 'Site[SITE]', use 'SELECTEDVALUE' on that column , it’s the simplest and most reliable:

    ----------DAX CODE--------

    Selected Site Target =
    VAR sel = UPPER( TRIM( SELECTEDVALUE( 'Site'[SITE], "" ) ) )
    RETURN
    SWITCH(
    TRUE(),
    sel = "LIV", [LIV FBDC Target],
    sel = "BUR", [FBDC TARGET],
    -- default when no single site selected: return RADW default 3000 (or BLANK() if you prefer)
    3000
    )

    ----------DAX CODE--------

    How this helps:

    • 'SELECTEDVALUE' returns the single slicer value (or ' "" ' when multiple/none).

    • 'TRIM' and 'UPPER' normalize the text.

    • The 'SWITCH(TRUE(), ...) pattern works well for string comparisons.

    If you prefer to show nothing until the user picks a single site, replace '3000' with 'BLANK( )'.

     

    Did I answer your question? Mark my post as a solution! This will help others on the forum!

    Appreciate your Kudos!!

    Jaywant Thorat | MCT | Data Analytics Coach
    Linkedin: https://www.linkedin.com/in/jaywantthorat/
    Join #MissionPowerBIBharat = https://shorturl.at/5ViW9