Forum Discussion
Date Calculator
- 7 years ago
Hi mwen90,
the DAX function DATEDIFF definition can be found here: https://docs.microsoft.com/en-us/dax/datediff-function-dax It says, the first param is StartDate and the second is EndDate. I think you should change the order in your Days expression.
Days = DATEDIFF(PlantEuipment_PlantEquipment[LastServiceDate];Today();DAY)
Then change the data type of LastServiceDay to date/time:
And I've also extend your DaysGroup logic to:
DaysGroup = IF ( PlantEuipment_PlantEquipment[Days] < 0; BLANK (); IF ( PlantEuipment_PlantEquipment[Days] <= 80; "Within service date"; IF ( PlantEuipment_PlantEquipment[Days] <= 90; "Approaching service date"; IF ( PlantEuipment_PlantEquipment[Days] > 90; "Service Required" ) ) ) )The result:
Hey Nolock thank you for that,
I can see the calculations are wrong. Is it something in the formula?
Hi mwen90,
have you renamed the column LastServiceDate to "Last Service Date" in your visual or do you have 2 different columns in your table? Have you taken the right column from the right table? Please check it or even better write the calculate column DAX code once again from scratch. I think you calculate DATEDIFF with a wrong column.
- mwen907 years agoHelper III
Hey,
I created a new column and did the datedIF formula for the Last Service Date column.
The column I have added is called 'days'.
I just redid it and it was the same result, Nolock
- Nolock7 years agoResident Rockstar
Hi mwen90,
please post your PBIX file to see why it is so. I can fix it then.
As you said in https://community.powerbi.com/t5/Desktop/DATEDIFF-incorrectly-calculating/td-p/368231/page/2 it can really be also your problem.
If you have 2 tables with the relationship 1:N and you try to get a difference of two values, you should always take just one value on both sides.
- mwen907 years agoHelper III
There isn't a table connected to it though so I am confused? Thanks so much for assisting,
I couldn't attach the file but please look at this URL -
Or - https://drive.google.com/drive/folders/1k6hjkJ-mCKHWjX7KjTLTyyqMHfT0lajA
Hopefully that works. Nolock thank you!!