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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
EbyEaso
Helper III
Helper III

Calculated Column based on Dates

I'm trying to find out the Aging of a case wcich registered in our system. In my dataset I have 2 date feilds. Assigned Date, and Completed Date.

 

I have created a calculated column by subtracting Assigned Date from Completed Date, I got the difference between and converted that value to Whole number so I can see how many days it took to complete it. But My problem is for some case there will be no Completed date so it wont give me exact how many days it is still there without complete.

 

So I want if there is no Completed Date then need calculate between Assigned Date to Todays date. And If Completed Date is available then calculate between Assigned Date and Completed Date.

Can someone help me.

 

Thnak You.

1 ACCEPTED SOLUTION

@EbyEaso OK, so:

= if 'SQL-DATE-UPDATED'[CompletedDate] = null then DateTime.LocalNow() - 'SQL-DATA-UPDATED'[AssignedToDate] else 'SQL-DATE-UPDATED'[CompletedDate] - 'SQL-DATA-UPDATED'[AssignedToDate]


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

7 REPLIES 7
Greg_Deckler
Community Champion
Community Champion

@EbyEaso Should be able to create an if statement that if the [Completed Date] = null then use DateTime.LocalNow in your calculation.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thank You. Appreciaet it.

 

My current calculation is this.

 

Aging = 'SQL-DATA-UPDATED'[CompletedDate]-'SQL-DATA-UPDATED'[AssignedToDate]

 

@EbyEaso OK, so:

= if 'SQL-DATE-UPDATED'[CompletedDate] = null then DateTime.LocalNow() - 'SQL-DATA-UPDATED'[AssignedToDate] else 'SQL-DATE-UPDATED'[CompletedDate] - 'SQL-DATA-UPDATED'[AssignedToDate]


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

It gives Syntax Error.

 

I put my actual query name.

 

EbyEaso_1-1664879243146.png

 

@EbyEaso Dude, you posted in the Power Query forum but it looks like you are trying to put Power Query code into a DAX calculated column. In DAX, that would be:

IF('SQL-DATE-UPDATED'[CompletedDate] = BLANK(), DATEDIFF(TODAY(),'SQL-DATA-UPDATED'[AssignedToDate],DAY), DATEDIFF('SQL-DATE-UPDATED'[CompletedDate], 'SQL-DATA-UPDATED'[AssignedToDate]))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Sorry @Greg_Deckler 

I'm beginner. 🙂 Trying to get solve these.

in DAX also i got error.

 

EbyEaso_0-1664881722666.png

And in Power Query I got this.

EbyEaso_0-1664882057703.png

 

 

@Greg_Deckler 

Finaly I got it. My Assigned To Date was in date time format. I think that was the issue. I changed that Date only format and added additional column to show todays date. Instead of using this

DateTime.LocalNow()

Now its fine.

 

Thank You @Greg_Deckler  for the valuable support. Appreciate it.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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