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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

How to get remaining days from current date (today date)?

Hi,

 

I need equation for add column to calculate remaining days from current date. The remaining days is between TODAY date to CLOSED DATE.

I already use DATEDIFF but it does't work because CLOSED DATE have date data before and after TODAY date.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

My apologies, try this instead:

Days Remaining = 
VAR ClosedDate = [Closed Date]
RETURN

SWITCH(
	TRUE,
	DATEVALUE(ClosedDate) < TODAY(), 0,
	DATEVALUE(ClosedDate) >= TODAY(), DateDiff(Today(), DATEVALUE(ClosedDate), DAY)
)

 

 

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

This is only work if you are refreshing your data at least once a day, but try this:

Days Remaining = 
VAR ClosedDate = [Closed Date]
RETURN

IF(
	ClosedDate > TODAY(),
	DateDiff(Today(), ClosedDate, DAY),
0 )
Anonymous
Not applicable

@Anonymous

What do you mean refreshing once a day? Need to refresh on power BI service and publish again or refresh on power Desktop?

 

Thanks

Anonymous
Not applicable

Calculated columns do their value calculation at the point in time that the refresh of the base data is downloaded.  If you don't refresh once a day, your values in this column will not change.

 

Typically in the Power BI Service you'll organise the refreshes directly (if on something like OneDrive) or through a gateway.

Anonymous
Not applicable

It doest not work for me, its has error below

 

DAX comparison operations do not support comparing values of type Text with values of type Date. Consider using the VALUE or FORMAT function to convert one of the values.

Anonymous
Not applicable

My apologies, try this instead:

Days Remaining = 
VAR ClosedDate = [Closed Date]
RETURN

SWITCH(
	TRUE,
	DATEVALUE(ClosedDate) < TODAY(), 0,
	DATEVALUE(ClosedDate) >= TODAY(), DateDiff(Today(), DATEVALUE(ClosedDate), DAY)
)

 

 

Anonymous
Not applicable

Hi, this might be helpful to me also. 

I am looking for the %completion of the year. 


Is the closed date in this example equivalent to the end of the year?

 

Example: today is April 20, 2020, the measure should display 30.28% (completion of the year).

I need this to be sliced per quarter and month too. 

 

Thanks in advance!

Anonymous
Not applicable

This will give you that percentage:

% Year Complete = var currentDate = TODAY()
var EOY = DATE(YEAR(currentDate), 12, 31)
var SOY = DATE(YEAR(currentDate), 1, 1)
var output = DIVIDE(
    currentDate - SOY,
    EOY - SOY
)
RETURN
output
Anonymous
Not applicable

Thanks for your reply. I already got the solution though

 

%Completion:=

Var Remaining = today()-FIRSTDATE('Calendar'[Date])

Var Totaldays = LASTDATE('Calendar'[Date])-FIRSTDATE('Calendar'[Date])+1

return

if((DIVIDE(Remaining,Totaldays))>1,1,if(divide(Remaining,Totaldays)<0,0,DIVIDE(Remaining,Totaldays)))

Anonymous
Not applicable

Hi @Anonymous

Its work now. Thanks for helping me.

 

Can you explain this coding phares operation?

 

VAR ClosedDate = [Date Closed Pbi]
RETURN

 

Thanks

Anonymous
Not applicable

Its referred to as a variable.  It places the data into memory meaning the statement doesn't have to keep referring back to the field every time it wants to use the value.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors