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
JennyMilf
Frequent Visitor

Get data within 1 day

Hello everyone, 

I want to get all the ID base on Register_datetime and Expire_datetime within 1 day. I tried the DATEDIFF function but it doesn't work like the photo below

Can anyone help me? Thanks

JennyMilf_1-1677812468828.png

Example: 

JennyMilf_0-1677814787249.png

 

2 ACCEPTED SOLUTIONS
vicky_
Super User
Super User

You need to return 1 value (instead of just filtering a table, which returns multiple lines) - instead of using FILTER... Try: 
IF(DATEDIFF(... etc.) <= 1, 1, BLANK().

That returns 1 when the DATEDIFF condition is True, and then you can use that as a filter.

View solution in original post

@JennyMilf , if you creating a column, you should be able to use

 

DATEDIFF([Date1], [Date2], day)

 

If you are creating a measure then try like

 

countrows(filter(Table, DATEDIFF([Date1], [Date2], day) <=1) )

View solution in original post

4 REPLIES 4
JennyMilf
Frequent Visitor

thank you, it's work!

JennyMilf
Frequent Visitor

Thank you for responding, But it seems like I can not use the DATEDIFF function and I don't know why. Do you have any idea? 

@JennyMilf , if you creating a column, you should be able to use

 

DATEDIFF([Date1], [Date2], day)

 

If you are creating a measure then try like

 

countrows(filter(Table, DATEDIFF([Date1], [Date2], day) <=1) )

vicky_
Super User
Super User

You need to return 1 value (instead of just filtering a table, which returns multiple lines) - instead of using FILTER... Try: 
IF(DATEDIFF(... etc.) <= 1, 1, BLANK().

That returns 1 when the DATEDIFF condition is True, and then you can use that as a filter.

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.