Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

filter time range value

Hello ,I want to filter data from 9pm to 9 am how to get this ,sharing my data table with you

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi  Anonymous ,

     

    Here are the steps you can follow:

    1. Create measure.

    Flag =
    
    var _len=LEN(MAX('Table'[Interval]))
    var _left=
    VALUE(
    IF(
        _len=10,LEFT(MAX('Table'[Interval]),1),LEFT(MAX('Table'[Interval]),2)))
    var _right=
    RIGHT(
        MAX('Table'[Interval]),2)
    var _flag=
    IF(
        _right="AM"&&_left=12,0,
        IF(
    _right="PM"&&_left<12,_left+12,_left))
    return
    IF(
        _flag>=9&&_flag<=9+12,1,0)

    2. Place [Flag]in Filters, set is=1, apply filter.

     

    3. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

3 Replies

  • Anonymous  Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

     

    Here are the steps you can follow:

    1. Create measure.

    Flag =
    
    var _len=LEN(MAX('Table'[Interval]))
    var _left=
    VALUE(
    IF(
        _len=10,LEFT(MAX('Table'[Interval]),1),LEFT(MAX('Table'[Interval]),2)))
    var _right=
    RIGHT(
        MAX('Table'[Interval]),2)
    var _flag=
    IF(
        _right="AM"&&_left=12,0,
        IF(
    _right="PM"&&_left<12,_left+12,_left))
    return
    IF(
        _flag>=9&&_flag<=9+12,1,0)

    2. Place [Flag]in Filters, set is=1, apply filter.

     

    3. Result:

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly