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
Anonymous
Not applicable

Filter out transactions in last 20 hours

Hi everyone. I have a table contains all transaction that happened last 7 days in factory. It has a column contains "Date Time" type of data that accurate to seconds. How can I create a visual that only display those transactions which happened in last 20 hours?

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Sample for your reference.

 

1. Create a measure as below.

 

Measure = 
VAR _now =
    NOW ()
VAR _diff =
    DATEDIFF ( MAX ( 'Table1'[date] ), [now], HOUR )
RETURN
    IF ( _diff <= 20 && _diff >= 0, 1, 0 )

2. Make the visual filtered by the measure.

Capture.PNG

 

Pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Sample for your reference.

 

1. Create a measure as below.

 

Measure = 
VAR _now =
    NOW ()
VAR _diff =
    DATEDIFF ( MAX ( 'Table1'[date] ), [now], HOUR )
RETURN
    IF ( _diff <= 20 && _diff >= 0, 1, 0 )

2. Make the visual filtered by the measure.

Capture.PNG

 

Pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
jsh121988
Employee
Employee

MyMeasure = 
CALCULATE(
    [SomeAggregate],
    FILTER(MyTable, [MyDateTime] >= MAX(MyTable[MyDateTime]) - (20/24))
)
MyMeasure = // ALL is used here to remove any filters from MAX(DateTime)
CALCULATE(
    [SomeAggregate],
    FILTER(MyTable, 
        [MyDateTime] >= CALCULATE( MAX(MyTable[MyDateTime]) - (20/24)), ALL(MyTable) )
)

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.