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
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
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.