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:
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.
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!!
- Nolock7 years agoResident Rockstar
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: