Forum Discussion
Filter Date with Buttons
Hi,
I really need help to create exactly the same thinng on this screenshot. The requirement is the user when click on the button report should dipslays selected time period. Even if I need to use DAX, please tell me step by step how I can do it. Here is screenshot and my data.
Thank you,
- Anonymous4 years ago
Hi Anonymous ,
Step1: Create a table like below and use it as slicer.
Step2: Create a measure as below and add it to visual filter.
Measure = var _time = SELECTEDVALUE('Table'[Time]) var _period = SELECTEDVALUE(Slicer[period]) return SWITCH(_period,"month",IF(_time>=EDATE(TODAY(),-1)&&_time<=TODAY()+1,1,0), "week",IF(_time>=TODAY()-7&&_time<=TODAY()+1,1,0), "12H",IF(_time>=TODAY()-2/24&&_time<=TODAY()+1,1,0), "24H",IF(_time>=TODAY()-1/24&&_time<=TODAY()+1,1,0))Step3: Set filter value = 1.
Best Regards,
Jay
3 Replies
- amitchandakSuper User
Anonymous , You have create an independent table with these values.
And then measure to filter based on the selected value
Switch ( selectedvalues(Slicer[Slicer]) ,
"2 Hour", calculate(Countrows(Table), Filter(Table, Table[Endtime] >= Now() -2 && Table[Endtime] <=now()),
"4 Hour", calculate(Countrows(Table), Filter(Table, Table[Endtime] >= Now() -4 && Table[Endtime] <=now()),
"month", calculate(Countrows(Table), Filter(Table,eomonth( Table[Endtime],-1) = eomonth(today(),0)),
//Add others
)
what we do for measure slicer
measure slicer
https://www.youtube.com/watch?v=b9352Vxuj-M
https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/500115
https://radacad.com/change-the-column-or-measure-value-in-a-power-bi-visual-by-selection-of-the-slicer-parameter-table-pattern- AnonymousNot applicable
amitchandak Thank you so much for repying! Please, can you give me more details? I never done before and I do not know where to start for this task. I will be happy if you really give more details step by step. Thank you.
- AnonymousNot applicable
Hi Anonymous ,
Step1: Create a table like below and use it as slicer.
Step2: Create a measure as below and add it to visual filter.
Measure = var _time = SELECTEDVALUE('Table'[Time]) var _period = SELECTEDVALUE(Slicer[period]) return SWITCH(_period,"month",IF(_time>=EDATE(TODAY(),-1)&&_time<=TODAY()+1,1,0), "week",IF(_time>=TODAY()-7&&_time<=TODAY()+1,1,0), "12H",IF(_time>=TODAY()-2/24&&_time<=TODAY()+1,1,0), "24H",IF(_time>=TODAY()-1/24&&_time<=TODAY()+1,1,0))Step3: Set filter value = 1.
Best Regards,
Jay