Forum Discussion
Days between two dates columns
Hello community,
I'm building a dashboard with Power BI Desktop.
I've connected a SQL server database which has two date fields:
[Transactiondate]
[Closed]
What I want to do is get the difference between these two in days.
I tried a DAX measure to find the difference( Closed - Transactiondate), but this gives me a weird date value.
Can someone help me with this problem?
15 Replies
- dramusContinued Contributor
There's also the DATEDIFF DAX function.
Days between = DATEDIFF([Transactiondate],[Closed],DAY)
- gkhareFrequent Visitor
Not working for me! I' am trying to take no.of days between close_date and start_date, it throws an error which says-The third argument Interval can only be one of the following: YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND...
I' am using the following expression
DaysLenght = DATEDIFF(AA_SALES_FACT[CLOSE_DATE],(AA_SALES_FACT[START_DATE]),DAY())
Request all gurus to kindly help me in fixing the above. I need to take the difference between Close_Date and Create_Date
- HarrisMalikContinued Contributor
gkhare there is a mistake in your formula the third argument to DATEDIFF is Interval not function. Use following formula:
DaysLenght = DATEDIFF(AA_SALES_FACT[CLOSE_DATE],AA_SALES_FACT[START_DATE],DAY)
- AnonymousNot applicable
diff = 1.0*([Closed]-[TransactionDate])
- AkahnAdvocate IV
Are you trying to do this calculation in a measure or a calcluated column?
- RémiResolver III
Hi Coelijoeli,
When you do the difference, Power BI will keep the same format. Then you have to convert your result in order to obtain what you want.
Then you can add format function, or you can choose a number format into the top ribbon.
- HaegiAdvocate V
Hi,
You can create a new measure with the dax formula by @Eno1978
Regards.