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
swaggerboy69
Helper IV
Helper IV

Need help adding status to dates

Hello guys!

 

I need help in adding status to dates.

For example the screenshot below, if it's beyond the due date, it will show as Overdue in the Status column. If it's 5 days before the due date, it'll say Almost due and if it's beyond 5 days before the due date, it'll say On time.

 

cond stat.JPG

1 ACCEPTED SOLUTION

Hi @swaggerboy69,

What type of result that you want to return if the current date is blank? Perhaps you can try this one and replace the 'N/A' with the result you wanted:

Due Status =
VAR _diff =
    DATEDIFF ( TODAY (), 'CR_Dashboard'[Due date], DAY )
RETURN
    IF (
        'CR_Dashboard'[Due date] <> BLANK (),
        IF ( _diff < 0, "Overdue", IF ( _diff < 5, "Almost Due", "On time" ) ),
        "N/A"
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

6 REPLIES 6
swaggerboy69
Helper IV
Helper IV

Can anyone help me with this please?

amitchandak
Super User
Super User

@swaggerboy69 , Try a new column like

new column =
var _diff = datediff([Date], today(),day)
return
switch(true(),
_diff<0 , "Overdue",
_diff<5 , "Almost Due",
"On Time"
)

There's inaccuracy of the data using that query.

I'm seeing October 28 as Almost due. It should be Overdue.

Also seeing October 31 as On Time. It should be Almost Due.

Additionally, if the Due date is blank, is there a way that it will retain as blank in the status?

Currently, it's saying Almost complete on blank Due dates.

HI @swaggerboy69,

Your table seems stored random dates with irregular value fields. Any available category and index use to filter records and find out the previous/next date based on current row contents?

In addition, it seems like your task code contains some numerical value that can work as index.
You can try to extract it and use it to find out the previous or next record, then you can calculate the diff between these and use if statement to mark and return tags.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

I was able to get it to work using the Query below:

Due Status =
var _diff = datediff(today(), 'CR_Dashboard'[Due date],day)
return
switch(true(),
_diff<0 , "Overdue",
_diff<5 , "Almost Due",
"On time"
)
 
However, my problem is that it shows as 'Almost Due' for fields with no date.
Can anyone help out?

Hi @swaggerboy69,

What type of result that you want to return if the current date is blank? Perhaps you can try this one and replace the 'N/A' with the result you wanted:

Due Status =
VAR _diff =
    DATEDIFF ( TODAY (), 'CR_Dashboard'[Due date], DAY )
RETURN
    IF (
        'CR_Dashboard'[Due date] <> BLANK (),
        IF ( _diff < 0, "Overdue", IF ( _diff < 5, "Almost Due", "On time" ) ),
        "N/A"
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.