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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
sandyn-2303
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 @sandyn-2303 

 

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 @sandyn-2303 ,

 

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 @sandyn-2303 ,

 

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 @sandyn-2303 

 

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.