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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
aqeel_shaikh
Helper II
Helper II

Aging(Days) column should be stopped

"Aging(Days)" column should be stopped when the "Project completion date" or "Expected completion date" is reached.


currently my aging is calculated as [Project Actual Start date - Today()] which is calculated field in powerbi. hence the aging doesn't stop.

 

data set is attached herewith.

 

Project Actual Start DateExpected Completion DateProject Completion DateAging(days)
06/02/2025 00:0003/03/2025 00:0001/03/2025 00:0026
01/02/2025 00:0028/02/2025 00:0025/02/2025 00:0031
26/02/2025 00:0005/03/2025 00:00 6
28/02/2025 00:0007/03/2025 00:0005/03/2025 00:004
15/01/2025 00:0005/02/2025 00:00 48
09/10/2024 00:0011/02/2025 00:00 146
03/02/2025 00:0019/02/2025 00:00 29
19/02/2025 00:0026/02/2025 00:00 13
10/02/2025 00:0010/04/2025 00:00 22
06/02/2025 00:0012/02/2025 00:0017/02/2025 00:0026
13/11/2024 00:0021/02/2025 00:0020/02/2025 00:00111

 

1 ACCEPTED SOLUTION

ok. You need to use aggregator function, like min, max etc. Try update the formula with min aggr. as follows:

Aging(Days) = 
VAR CompletionDate = 
    IF(
        NOT(ISBLANK(MIN('Procurement Project'[Project Completion Date]))),
        MIN('Procurement Project'[Project Completion Date]),
        MIN('Procurement Project'[Expected Completion Date])
    )
RETURN
    IF(
        NOT(ISBLANK(CompletionDate)),
        DATEDIFF(MIN('Procurement Project'[Project Actual Start Date]), CompletionDate, DAY),
        DATEDIFF(MIN('Procurement Project'[Project Actual Start Date]), TODAY(), DAY)
    )

 

Hope this helps!! 

View solution in original post

8 REPLIES 8
danextian
Super User
Super User

Hi @aqeel_shaikh 

 

Try this:

DATEDIFF (
    'table'[project start date],
    COALESCE ( 'table'[project completion  date], TODAY () ),
    DAY
)

COALESCE will return the first non-blank value so if there's a  value for completion date, that will be the end date else TODAY().





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

getting below error...pls. help!

aqeel_shaikh_0-1741077268636.png

 

Ageing(Days) = 
   DATEDIFF(FILTER('Procurement Project','Procurement Project'[Project Actual Start Date].[Date], 
   COALESCE(FILTER('Procurement Project','Procurement Project'[Expected Completion Date].[Date], TODAY() ), DAY
   )))

 

That is to be written as a calculated column.

Age = 
DATEDIFF (
    'Table'[Project Actual Start Date],
    COALESCE ( 'Table'[Expected Completion Date], TODAY () ),
    DAY
)

danextian_0-1741084811772.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
shafiz_p
Super User
Super User

Hi @aqeel_shaikh  Try this:

Aging(Days) = 
VAR CompletionDate = 
    IF(
        NOT(ISBLANK('Table'[Project Completion Date])),
        'Table'[Project Completion Date],
        'Table'[Expected Completion Date]
    )
RETURN
    IF(
        NOT(ISBLANK(CompletionDate)),
        DATEDIFF('Table'[Project Actual Start Date], CompletionDate, DAY),
        DATEDIFF('Table'[Project Actual Start Date], TODAY(), DAY)
    )

 

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

@shafiz_p - Hi, can you please check what is wrong here iam getting error

aqeel_shaikh_0-1741075515307.png

 

 

Ageing(Days) = 
VAR CompletionDate = 
    IF(
        NOT(ISBLANK('Procurement Project'[ProjectCompletionDate])),
        'Procurement Project'[ProjectCompletionDate],
        'Procurement Project'[Expected Completion Date]
    )
RETURN
    IF(
        NOT(ISBLANK(CompletionDate)),
        DATEDIFF('Procurement Project'[Project Actual Start Date], CompletionDate, DAY),
        DATEDIFF('Procurement Project'[Project Actual Start Date], TODAY(), DAY)
    )

 

 

ok. You need to use aggregator function, like min, max etc. Try update the formula with min aggr. as follows:

Aging(Days) = 
VAR CompletionDate = 
    IF(
        NOT(ISBLANK(MIN('Procurement Project'[Project Completion Date]))),
        MIN('Procurement Project'[Project Completion Date]),
        MIN('Procurement Project'[Expected Completion Date])
    )
RETURN
    IF(
        NOT(ISBLANK(CompletionDate)),
        DATEDIFF(MIN('Procurement Project'[Project Actual Start Date]), CompletionDate, DAY),
        DATEDIFF(MIN('Procurement Project'[Project Actual Start Date]), TODAY(), DAY)
    )

 

Hope this helps!! 

@shafiz_p , @danextian Thanks it worked

Thanks Shahariar, just one more thing i have multiple table in powerbi, now by default the table is selected as per alphbetical order. and the table in powerbi is Procurement Project, can you please rewrite the above script so i can pull the table.

regards,

Aqeel

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.