Forum Discussion
Date functions in Power Bi
Hi,
Thanks for the solution ChiragGarg2512 provided, it is excellent, and I want to offer some more informatio for user to refer to.
hello Su2020 , based on your description, you can modify your code to the following in power bi, you need to create calculated columns in table.
Status Update Days = IF(ISBLANK([POSTED ON]),0,DATEDIFF([POSTED ON],TODAY(),DAY))Status Update Comment =
IF (
ISBLANK ( [Status Update Days] ),
"Project has never been updated",
IF (
DAY ( TODAY () ) * [Status Update Days] <= 0,
"Project has not been updated",
IF (
[Status Update Days] <= 14,
"Updated",
IF (
[Status Update Days] >= 30,
"Project is not updated more than 1 month",
"Project is not updated more than 2 weeks"
)
)
)
)
Project total Past Due Date Days =IF(ISBLANK([start data]),0,DATEDIFF([start date],TODAY(),DAY))Project Due Date Status =
VAR a =
DATEDIFF ( [due date], TODAY (), DAY )
RETURN
IF (
ISBLANK ( [Due date] ),
"Project has no due date",
IF ( a > 1, "Project has past due date", "Project is not due yet" )
)
Projects Deliverables Status =
IF (
OR (
[Projects Deliverables] = "Not Provided",
ISBLANK ( [Projects Deliverables] )
),
"Not Provided",
"Provided"
)
Sample Output
As ChiragGarg2512 mentionded, if you want to extract the day of today, you need to use the day() funciton, and you can use DATEDIFF() function to calculate the difference between two dates.
You can refer to the following link abount the functions.
DATEDIFF function (DAX) - DAX | Microsoft Learn
DAY function (DAX) - DAX | Microsoft Learn
If the solutions ChiragGarg2512 and I provided help you solve the problem, please consider to mark them as the solution.
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.