Forum Discussion
Filter by date and time
Hello,
I would like to ask for help!
I would like to set up a dynamic filtering option that would pre-filter the data based on the criteria you specify.
The start date is always the previous day and 6am. The end date: is always today and 6am. So I want to see the data between the time interval. I could do this for date, but not for time.
In the table, the date and time are in two separate columns, if it is easier I can merge them.
What are the options?
Thank you very much for your help!
Best regards,
Atis
Hi , Atis112
According to your description, you want to filter the data from previous day 6am to today 6am.
Here are the steps you can refer to :
(1)This is my test data:
(2)We can create a measure like this:
Measure = var _today = TODAY() var _previoud_day = TODAY()-1 var _cur_day = MAX('Table'[Date]) var _cur_time = MAX('Table'[Time]) return IF( OR( _cur_day= _today && _cur_time<= TIME(6,0,0) , _cur_day= _previoud_day && _cur_time>= TIME(6,0,0) ) ,1,-1)(3)Then we can put the measure on the visual and configure it:
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
5 Replies
- v-yueyunzh-msft
Community Support
Hi , Atis112
According to your description, you want to filter the data from previous day 6am to today 6am.
Here are the steps you can refer to :
(1)This is my test data:
(2)We can create a measure like this:
Measure = var _today = TODAY() var _previoud_day = TODAY()-1 var _cur_day = MAX('Table'[Date]) var _cur_time = MAX('Table'[Time]) return IF( OR( _cur_day= _today && _cur_time<= TIME(6,0,0) , _cur_day= _previoud_day && _cur_time>= TIME(6,0,0) ) ,1,-1)(3)Then we can put the measure on the visual and configure it:
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- Atis112New Member
Hello, v-yueyunzh-msft
Whoa. Yes, that's what I meant. Very perfect! Thank you very much for your help and the description of the process. It totally solved the problem!
I have another question on the same subject:
How can I set up slicer to list out based on start date start time and end date and end time. For example, with a slicer of four, can this be done? Do you have any ideas for this?
- Atis112New Member
Hello,
Yes, You can find it here:
Part number ID Date Time Quantity 123456789x 1234 2023.02.03 5:45 1 123456799x 1235 2023.02.03 6:30 5 123456789x 1236 2023.02.03 22:20 110 123456799x 1237 2023.04.04 23:45 78 123456789x 1238 2023.04.04 3:10 67 123456799x 1239 2023.04.04 16:22 50 123456789x 1240 2023.02.01 5:10 765 123456799x 1241 2023.02.02 6:11 864 123456789x 1242 2023.02.03 17:15 324 123456799x 1243 2023.02.04 14:11 23 123456789x 1244 2023.02.05 18:44 234 123456799x 1245 2023.02.06 21:34 56 123456789x 1246 2023.02.07 8:10 876 123456799x 1247 2023.03.01 11:43 43 123456789x 1248 2023.02.09 11:01 34 123456799x 1249 2023.02.10 18:30 76 Thank you very much!