cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rmcmun
Frequent Visitor

Filter +/- 24 hours

Hi all,

 

I'm trying to filter a visualization so that it displays plus and minus 24 hours from the current time.

E.g., It is now 11:00 Jan 22, so my chart should display from 11:00 Jan 21 to 11:00 Jan 23?

 

How can I do this?

 

Thanks so much!

1 ACCEPTED SOLUTION
Eyelyn9
Community Support
Community Support

Hi @rmcmun ,

 

You could use the following formula to create a new measure :

Measure =
IF (
    MAX ( 'Table'[Production output time] )
        >= NOW () - 1
        && MAX ( 'Table'[Production output time] )
            <= NOW () + 1,
    1,
    0
)

And apply it to filter pane(set as "is 1") like this:

1.25.4.1.gif

Please take a look at the pbix file here.

 

Best Regards,
Eyelyn Qin
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

7 REPLIES 7
Eyelyn9
Community Support
Community Support

Hi @rmcmun ,

 

You could use the following formula to create a new measure :

Measure =
IF (
    MAX ( 'Table'[Production output time] )
        >= NOW () - 1
        && MAX ( 'Table'[Production output time] )
            <= NOW () + 1,
    1,
    0
)

And apply it to filter pane(set as "is 1") like this:

1.25.4.1.gif

Please take a look at the pbix file here.

 

Best Regards,
Eyelyn Qin
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

PC2790
Impactful Individual
Impactful Individual

Hi @rmcmun ,

 

You can simply do it by fetching the current time and adding 24/24 to it, DAX of the measure would look like:

 

Time(-24) = NOW() - 1
Time(+24) = NOW() + 1
 
Thanks
rmcmun
Frequent Visitor

Thanks @PC2790 !

I have just posted more clarification in respose to @vanessafvg . If I create those measures, how would I then use that to filter the chart? 

 

Thanks!

PC2790
Impactful Individual
Impactful Individual

For that you cna use a 'Relative time slicer'. It will automatically get you the data of last/next 24 hours.

 

PC2790_0-1611321405214.pngPC2790_1-1611321426040.png

 

rmcmun
Frequent Visitor

I can add the relative time slicer to add either the last or the next 24 hours, but I don't seem to be able to select BOTH the last and next 24 hours.

 

Is that possible?

Thanks

vanessafvg
Super User I
Super User I

can you give more details.  do you want this on the slicer, what type of visual are you using. providing the right amount of detail helps to get the right response.

 

screen shots and sample data help too.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks @vanessafvg,

I'm using a line chart and trying to plot expected vs. actual outputs on a production line (see screenshot).

Screenshot 2021-01-22 at 11.41.39.png

 

The fact table I'm plotting from (simplifying) has the following fields:

 

- Production output time (datetime)

- Production output volume (decimal)

- Type (text = actual or expected)

 

So I need to filter the chart so that it is only displaying the actual vs. expected outputs for -24 hours and +24 hours from now.

 

Does that make sense?

 

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

March Update

Check it Out!

Click here to read more about the March 2021 Updates!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

secondImage

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.