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

Created Date is within Current Week, Past Two Weeks, etc.

Hi Everyone

 

Thanks for reading!  I'm trying to create an open ticket tracker that shows tickets as green, yellow, orange, and red depending on if they're just open in the current week, past two weeks, past month, or older than a month.  I think I've got everything except those bins.  I figure the easiest way is to make a custom column that bins them based on date functions, but it doesn't seem to be working.  I'm new to Power BI, though, so maybe I've missed something.

 

Here is my column query:

 

=if [Created Time] is null then null else if Date.IsInCurrentWeek([Created Time]) then "Current Week" else if Date.IsInPreviousNWeeks([Created Time], 2) then "Past Two Weeks" else if Date.IsInCurrentMonth([Created Time]) then "Past Month" else "Older Than a Month"

 

Everything is returning as "Older Than a Month."  Any ideas?

 

My [Created Time] looks like this: 1/11/2023 10:39:00 AM

The date queries are supposed to work on datetime queries, so I didn't think that would be a problem.

 

Thanks!

1 ACCEPTED SOLUTION
ChelseaLearned
Frequent Visitor

Thanks for your help!  I found out what I initially did actually worked, just the preview wasn't loading all data.  I had to click "Load more" when selecting the dropdown for the calculated column.

View solution in original post

2 REPLIES 2
ChelseaLearned
Frequent Visitor

Thanks for your help!  I found out what I initially did actually worked, just the preview wasn't loading all data.  I had to click "Load more" when selecting the dropdown for the calculated column.

amitchandak
Super User
Super User

@ChelseaLearned , Try this in a new column. Trying to use date, in the place of date time

 

let
_create = DateTime.Date([Created Time]),
_result = if _create is null then null else if Date.IsInCurrentWeek(_create) then "Current Week" else if Date.IsInPreviousNWeeks(_create, 2) then "Past Two Weeks" else if Date.IsInCurrentMonth(_create) then "Past Month" else "Older Than a Month"

in
_result

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.