Forum Discussion

JB_AT's avatar
JB_AT
Helper III
2 years ago
Solved

Measure to Filter Visual

Hello

I am trying to filter a visual to show Employees who's birthday appears in the selected month in a slicer. I have the below measure which works partially, but only when the measure is added to the visual. i also have the measure set to Is 1 in the filter pane. I want to only add it to the Filter Pane of the visual and choose 1. But when I remove the measure from the visual everything returns blank. What Is missing here? I also want the measure to ignore any Year selected in the Year Slicer, that's why I have ALL(DIM_Date)

IF (
    HASONEVALUE ( DIM_Date[MonthNo] ),
    IF (
        MONTH (
            CALCULATE (
                MAX ( 'Employment'[DateofBirth] ),
                ALL ( DIM_Date ),
                USERELATIONSHIP ( 'DIM_Date'[Date], 'Employment'[DateofBirth] )
            )
        ) = SELECTEDVALUE ( DIM_Date[MonthNo] ),
        1,
        0
    ),
    BLANK ()
)

 
Thanks

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, JB_AT 

    May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

     

     

    Measures:

    EmployeeBirthday =
    
    VAR _selectedMonth =
    
        SELECTEDVALUE ( 'Month'[Month] )
    
    VAR _EmpBirthdayMonth =
    
        CALCULATE (
    
            COUNTROWS ( Employment ),
    
            FILTER ( Employment, Employment[Birthday].[MonthNo] = _selectedMonth )
    
        )
    
    RETURN
    
        IF ( ISFILTERED ( 'Month'[Month] ), _EmpBirthdayMonth, 1 )

     

    If this does not work, could you please share some sample data without sensitive information and expected output.
    How to provide sample data in the Power BI Forum - Microsoft Fabric Community

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, JB_AT 

    May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

     

     

    Measures:

    EmployeeBirthday =
    
    VAR _selectedMonth =
    
        SELECTEDVALUE ( 'Month'[Month] )
    
    VAR _EmpBirthdayMonth =
    
        CALCULATE (
    
            COUNTROWS ( Employment ),
    
            FILTER ( Employment, Employment[Birthday].[MonthNo] = _selectedMonth )
    
        )
    
    RETURN
    
        IF ( ISFILTERED ( 'Month'[Month] ), _EmpBirthdayMonth, 1 )

     

    If this does not work, could you please share some sample data without sensitive information and expected output.
    How to provide sample data in the Power BI Forum - Microsoft Fabric Community

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly --  How to provide sample data in the Power BI Forum