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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.