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

Get Previous and Next Dates for a given date and determine project Status

I have a table with a column of bi-weekly dates to Refresh dashboard. (Thanks to this forum! I could lookup and create this table). I have another table which has the Status Updated Date for an Initiative. As an output, on any day, I need to get the previous and next refresh date closest for that day. Then based on the status updated date, determine if project status is Good/Due/Past Due.

Refresh Table - 

naidu_sandhya_0-1660372382320.png

Status Updated Table - 

naidu_sandhya_1-1660372571070.png

Output - As of today - 08/13/2022, I want to display the below.

That is -

"Good", if the Status Updated Date is greater than the previous refresh data and lesser than the next refresh date

"Due", if the Status Updated Date is Due before next refresh date

"Past Due", if the Status Updated Date is older than 2 previous refresh dates

naidu_sandhya_4-1660374317800.png

My problem is

1. I am not able to get the Previous Refresh Date and Next Refresh Date from the Refresh Table as of today (8/13/2022)

2. How to determine the Project Status as Good / Due / Past Due ?

 

Any help is much appreciated!

 

Thanks!

 

 

 

 

2 ACCEPTED SOLUTIONS
daXtreme
Solution Sage
Solution Sage

Hi @naidu_sandhya 

 

Here's a solution. But the logic you gave... well, you have to revise it as it appears a bit flawed. The link is to a pbix file on my OneDrive. Please download the file and inspect. You should be able to adjust it to your liking.

View solution in original post

v-cgao-msft
Community Support
Community Support

Hi @naidu_sandhya ,

 

Please try these measures:

Prvious refresh date = 
CALCULATE (
    MAX ( 'RefreshTable'[Refresh Date] ),
    'RefreshTable'[Refresh Date] < TODAY ()
)
Next refresh date = 
CALCULATE (
    MIN ( 'RefreshTable'[Refresh Date] ),
    'RefreshTable'[Refresh Date] >= TODAY ()
)
Project Status = 
VAR _statusupdated =
    MAX ( 'StatusUpdatedTable'[Status Updated] )
VAR _previousrefreshdate = [Prvious refresh date]
VAR _2previousrefreshdate =
    CALCULATE (
        MAX ( 'RefreshTable'[Refresh Date] ),
        'RefreshTable'[Refresh Date] < _previousrefreshdate
    )
VAR _status =
    SWITCH (
        TRUE (),
        _statusupdated >= [Prvious refresh date]
            && _statusupdated <= [Next refresh date], "Good",
        _statusupdated < [Prvious refresh date]
            && _statusupdated >= _2previousrefreshdate, "Due",
        _statusupdated < _2previousrefreshdate, "Past Due"
    )
RETURN
    _status

vcgaomsft_0-1660718065386.png

The PBIX file is attached for reference:

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

3 REPLIES 3
v-cgao-msft
Community Support
Community Support

Hi @naidu_sandhya ,

 

Please try these measures:

Prvious refresh date = 
CALCULATE (
    MAX ( 'RefreshTable'[Refresh Date] ),
    'RefreshTable'[Refresh Date] < TODAY ()
)
Next refresh date = 
CALCULATE (
    MIN ( 'RefreshTable'[Refresh Date] ),
    'RefreshTable'[Refresh Date] >= TODAY ()
)
Project Status = 
VAR _statusupdated =
    MAX ( 'StatusUpdatedTable'[Status Updated] )
VAR _previousrefreshdate = [Prvious refresh date]
VAR _2previousrefreshdate =
    CALCULATE (
        MAX ( 'RefreshTable'[Refresh Date] ),
        'RefreshTable'[Refresh Date] < _previousrefreshdate
    )
VAR _status =
    SWITCH (
        TRUE (),
        _statusupdated >= [Prvious refresh date]
            && _statusupdated <= [Next refresh date], "Good",
        _statusupdated < [Prvious refresh date]
            && _statusupdated >= _2previousrefreshdate, "Due",
        _statusupdated < _2previousrefreshdate, "Past Due"
    )
RETURN
    _status

vcgaomsft_0-1660718065386.png

The PBIX file is attached for reference:

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

daXtreme
Solution Sage
Solution Sage

Hi @naidu_sandhya 

 

Here's a solution. But the logic you gave... well, you have to revise it as it appears a bit flawed. The link is to a pbix file on my OneDrive. Please download the file and inspect. You should be able to adjust it to your liking.

Thank you very much!! I did not expect a response this quick!! 🙂 

 

I might not have written the logic exactly right. Please correct me where is the flaw? 

 

What you gave me works fine infact. I have just a followup question. Imagine if today was 8/1/2022, is it possible to still show the previous refresh date as 7/18/2022 and next refresh date is 8/1/2022 as the refresh cycle ends by EOD of 8/1/2022 ?

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.

Top Solution Authors