Oct 27 2020 08:27 AM
Hi, all. I have developed a power pivot and I am seeking to find the number of days between two dates. I have tried DATEDIFF unsuccessfully. Any hints/tips on how to calculate this? On the screenshot below I am seeking to get the number of days between the "BeginHarvestDate" and the "PlantDate". Thanks for any help!
Oct 27 2020 08:51 AM
You may simply try this...
Number of Days:=DATEDIFF(DaysToHarvest[plantdate],[beginharvestdate],DAY)
Oct 27 2020 01:15 PM
As variant in DAX that could be as well
=INT(Table1[End]-Table1[Start])
but why don't you do this transformation in Power Query since the table generated in it. That's like
..., each Duration.Days(Duration.From([End]-[Start]))
In general it's better to avoid calculated columns generated by DAX in data model if you can do them in Power Query.
Oct 27 2020 02:07 PM
@Sergei Baklan Thank you. I will execute this in Power Query - thanks for that advice. I am having trouble with your formula in the power query editor. I used: Duration.Days(#duration[beginharvestdate]-[plantdate])
That formula is yielding an expression error: We cannot apply field access to the type function. Details:
Value=[Function]
Key=beginharvestdate
Any thoughts on what I am doing wrong?
Oct 27 2020 09:01 PM
Oct 28 2020 07:52 AM
@Subodh_Tiwari_sktneer Thank you, Sir. Very helpful.