Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Atis112
New Member

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

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
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:

vyueyunzhmsft_0-1675650187169.png

(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:

vyueyunzhmsft_1-1675650227553.png

 

 

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

 

View solution in original post

5 REPLIES 5
v-yueyunzh-msft
Community Support
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:

vyueyunzhmsft_0-1675650187169.png

(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:

vyueyunzhmsft_1-1675650227553.png

 

 

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

 

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?

FreemanZ
Super User
Super User

hi @Atis112 

could you paste some sample data?

Hello,

@FreemanZ 

Yes, You can find it here:

Part numberIDDateTimeQuantity
123456789x12342023.02.035:451
123456799x12352023.02.036:305
123456789x12362023.02.0322:20110
123456799x12372023.04.0423:4578
123456789x12382023.04.043:1067
123456799x12392023.04.0416:2250
123456789x12402023.02.015:10765
123456799x12412023.02.026:11864
123456789x12422023.02.0317:15324
123456799x12432023.02.0414:1123
123456789x12442023.02.0518:44234
123456799x12452023.02.0621:3456
123456789x12462023.02.078:10876
123456799x12472023.03.0111:4343
123456789x12482023.02.0911:0134
123456799x12492023.02.1018:3076

 

Thank you very much!

hi @Atis112 

when you say "see the data between the time interval", are you expecting to showcase that part of the table, or perform some further aggregation?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors