Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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,
Solved! Go to Solution.
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
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
@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
@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.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 36 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |