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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
v-eqin-msft
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
v-eqin-msft
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.

PC2790
Community Champion
Community Champion

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
Community Champion
Community Champion

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
Super User

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.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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