Forum Discussion

SSBkrish's avatar
SSBkrish
Regular Visitor
2 years ago
Solved

shift Number should change automaticlly in slicer

Hi Experties,
I would like to set shift number details in the slicers and shift number should change automatically once 1st shift completes.
Ex : 1st shift 8 AM to 4 PM and 2nd shift timings 4 PM to 10 PM .
Slicer filter value should change after 4PM automaticlly. 
Any help here..
Thanks Advance

 

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi SSBkrish ,

     

    danextian  dharmendars007 , thanks for your concern about this case. I tried to create a sample data myself based on the user's requirement and implemented the result. Please check if there is anything that can be improved. Here is my solution:

     

    Since it is not possible to dynamically and automatically select options in a slicer, you may consider setting dynamic filtering conditions for the visuals or the page you need to filter. To achieve this, you can create a measure and apply it as a filter.

     

    1\My Date source(Table)

    2\Create a measure

    FilterOnThisMeasuer = If(Hour(NOW())>=8 && Hour(NOW())<=16 && MAX('Table'[Shift])="1st shift" ,1,0)

    3\Filter on this measure 

    Best Regards,

    Bof

     

3 Replies

  • Hello SSBkrish , 

     

    You can create the below table with shifts and add it as slicer..then write the below DAX to get the result.

     

    Shift Number Start Time End Time

    1st Shift8:00 AM4:00 PM
    2nd Shift4:00 PM10:00 PM

     

    Current Shift =
    VAR CurrentTime = TIME(HOUR(NOW()), MINUTE(NOW()), SECOND(NOW()))
    RETURN
    SWITCH(
    TRUE(),
    CurrentTime >= TIME(8, 0, 0) && CurrentTime < TIME(16, 0, 0), "1st Shift",
    CurrentTime >= TIME(16, 0, 0) && CurrentTime < TIME(22, 0, 0), "2nd Shift",
    "Outside Shifts")

     

    please make sure your report is refreshed becasue without report refresh your shift timings wont change.

     

    If you find this helpful , please mark it as solution and Your Kudos are much appreciated!

     

    Thank You

    Dharmendar S

    LinkedIN 

     

     

  • Hi SSBkrish 

     

    You can leverage the Group By Columns property (accessible using Tabular Editor)  to store a fitler by using an alternate value. You can create a calculated column that check the current time and compare it agains the the shift column. For example

    CurrentShift =
    IF (
        UTCNOW () + DIVIDE ( 8, 24 )
            >= DIVIDE ( 16, 24 )
            && 'table'[shift] = "4PM AM to 10 PM",
        1,
        0
    )
    -- 8 means GMT+8, change it to your timezone.
    

    Use the above calcualted column in the Group By Colums property.  Please note that calculated columns do not update unless the underlying reference table/column updates so the value of UTCNOW() is based  on the latest refresh. That said, you need to refresh your semantic model after 4PM so that value updates as well. Here's an example of how that column property is leverage. Further reading can be found in the video description, including its current limitations.

    https://www.youtube.com/watch?v=MrEAZREQuXM 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi SSBkrish ,

     

    danextian  dharmendars007 , thanks for your concern about this case. I tried to create a sample data myself based on the user's requirement and implemented the result. Please check if there is anything that can be improved. Here is my solution:

     

    Since it is not possible to dynamically and automatically select options in a slicer, you may consider setting dynamic filtering conditions for the visuals or the page you need to filter. To achieve this, you can create a measure and apply it as a filter.

     

    1\My Date source(Table)

    2\Create a measure

    FilterOnThisMeasuer = If(Hour(NOW())>=8 && Hour(NOW())<=16 && MAX('Table'[Shift])="1st shift" ,1,0)

    3\Filter on this measure 

    Best Regards,

    Bof