Forum Discussion

cheid_4838's avatar
cheid_4838
Icon for Helper IV rankHelper IV
1 year ago
Solved

How to show single value with interaction between visuals and max value?

I have two tables (Components and mechanicid) that show cost, total hours, averagehours, and max labor hours.  My goal with these two tables is for the user to select the max labor hour from the comp...
  • v-veshwara-msft's avatar
    1 year ago

    Hi cheid_4838 ,

    Thanks for posting your question in Microsoft Fabric Community.

    I reproduced the scenario using the sample structure you described. 

    The approach shared earlier by Sandip_Palit using the Show Mechanic for Max Hours measure works correctly when evaluated in the row context of the mechanics visual. I followed that logic but slightly adjusted the setup to handle both cases: when a component is selected and when nothing is selected (so all rows show by default).

     

    To achieve the behavior where selecting a row in the Components table filters the Mechanic table to show only the record with the matching max labor hours, you can use the following measure:

    SelectedComponentMaxHours = 
    CALCULATE (
        MAX (ComponentLabor[Max Labor Hours]),
        ALLEXCEPT (ComponentLabor, ComponentLabor[ComponentDesc])
    )

     

    Then use this filter measure on your mechanic visual:

    ShowOnlyMaxMechanic = 
    VAR _SelectedMax =
        CALCULATE (
            MAX (ComponentLabor[Max Labor Hours]),
            ALLEXCEPT (ComponentLabor, ComponentLabor[ComponentDesc])
        )
    
    VAR _IsFiltered =
        ISFILTERED (ComponentLabor[ComponentDesc])
    
    RETURN
        IF (
            NOT _IsFiltered || MAX(MechanicLabor[Max Labor Hours]) = _SelectedMax,
            1,
            0
        )

     

    Apply ShowOnlyMaxMechanic = 1 as a visual-level filter on the mechanic table visual. This ensures that when a component is selected, only the mechanic(s) with matching max labor hours will show, and when no selection is made, all rows will be visible.

     

    Result:
    Without selection:

     

    When selected:

     

    Attached is the .pbix for reference.

    Thanks Sandip_Palit for your suggestions and approach.

     

    Hope this helps. Please reach out for further assistance.

    Thank you.