Forum Discussion
RT6
2 years agoFrequent Visitor
DAX, Previous Shift, previous Week Dynamic Switch
Hi all, i have a datasets with several records including timestamp. The requirement is to have a filter to be able to select 1). Current Shift (6:00-14:00, 14:00-22:00, 22:00-6:00) 2). Today O...
amitchandak
2 years agoSuper User
RT6 , I think you should explore offset function with an order by partition by
Continue to explore Power BI Offset Compare Categories, Time Intelligence MOM, QOQ, and YOY: https://youtu.be/5YMlkDNGr0U
RT6
2 years agoFrequent Visitor
Hi Amitchandak, thanks for your response, for now the solution was to create measures for each period and use Dynamic Switch:
Dynamic_TotalTime_Diff =
SWITCH(
SELECTEDVALUE(SlicerTable[Period]),
"Current Shift", [_CS_TotalTimeDiff],
"Today", [_Today_TotalTimeDiff],
"This Week", [_ThisWeek_TotalTimeDiff],
"This Month", [_ThisMonth_TotalTimeDiff],
BLANK()
)
And Slicer Table:
SlicerTable =
DATATABLE(
"Period", STRING,
"Order", INTEGER,
{
{"Current Shift", 1},
{"Today", 2},
{"This Week", 3},
{"This Month", 4}
}
)
It seems to be working🙂