Forum Discussion

Sharvari2102's avatar
Sharvari2102
Regular Visitor
2 months ago
Solved

Time Filter Slicer

Hello everyone, I am currently working on a Power BI dashboard where I need to filter data based on time. At the moment, I’m using a standard slicer on a time column, but it is not very user-frien...
  • oussamahaimoud's avatar
    2 months ago

    Hi Sharvari2102,

     

    You should Convert your time column to an integer (minutes since midnight) and use the numeric range slicer (Between mode). This gives users two clean input boxes, exactly like the screenshot you shared, without scrolling or search workarounds.

     

    Here's what you can do step by step:

     

    Step 1 Create a calculated column or transform in Power Query:

    Time As Minutes = Hour([TimeColumn]) * 60 + Minute([TimeColumn])

     

    Step 2: Add a Numeric Range Slicer on Time As Minutes, set to Between.

     

    Step 3: Adapt your measure to work with the integer range:

    Records Outside Range =

    VAR StartMin = MIN('Slicer'[Time As Minutes])

    VAR EndMin = MAX('Slicer'[Time As Minutes])

    RETURN

    CALCULATE(

        COUNTROWS('YourTable'),

        'YourTable'[Time As Minutes] < StartMin

            || 'YourTable'[Time As Minutes] > EndMin

    )

     

    Step 4 (optional): format display labels using a helper measure so axis/tooltip shows HH:MM instead of raw integers:

    Format Minutes =

    VAR M = SELECTEDVALUE('YourTable'[Time As Minutes])

    RETURN

        FORMAT(TIME(INT(M/60), MOD(M,60), 0), "HH:MM")

     

    Hope this helps! Don't forget to accept as solution and give a like in order to keep helping others.

     

    Best regards,

    Oussama (Data Consultant - Expert Fabric & Power BI)