Forum Discussion
Calculation groups to switch between dates not working as expected
- 1 year ago
Hi gustavog80
The issue appears to be that the columns sample_dataset[Tenant Lease Executed] and sample_dataset[Forecast Month] each contain values with non-zero time components, so they are not pure "dates".
This is causing inconsistent results since the relationship with 'Calendar' relies on having date values with no time component in order to filter correctly.
I would recommend changing the types of both columns to date in either the source file or Power Query.
While those columns have been changed to Data type = Date in the Power BI model interface, this does not remove the time component of the values, but merely hides it. Date and DateTime are really the same underlying type when loaded to the model. To be certain of "dates" being loaded, the type must be changed upstream, in Power Query or source.
You can verify that this is the issue by running a query like this in the DAX Query view:
EVALUATE SELECTCOLUMNS( SUMMARIZE( sample_dataset, sample_dataset[Tenant Lease Executed], sample_dataset[Forecast Month] ), "Tenant Lease Executed Formatted", FORMAT( sample_dataset[Tenant Lease Executed], "yyyy-MM-dd HH:mm:ss" ), "Forecast Month Formatted", FORMAT( sample_dataset[Forecast Month], "yyyy-MM-dd HH:mm:ss" ) ) ORDER BY [Tenant Lease Executed Formatted], [Forecast Month Formatted]
Hi gustavog80
The issue appears to be that the columns sample_dataset[Tenant Lease Executed] and sample_dataset[Forecast Month] each contain values with non-zero time components, so they are not pure "dates".
This is causing inconsistent results since the relationship with 'Calendar' relies on having date values with no time component in order to filter correctly.
I would recommend changing the types of both columns to date in either the source file or Power Query.
While those columns have been changed to Data type = Date in the Power BI model interface, this does not remove the time component of the values, but merely hides it. Date and DateTime are really the same underlying type when loaded to the model. To be certain of "dates" being loaded, the type must be changed upstream, in Power Query or source.
You can verify that this is the issue by running a query like this in the DAX Query view:
EVALUATE
SELECTCOLUMNS(
SUMMARIZE(
sample_dataset,
sample_dataset[Tenant Lease Executed],
sample_dataset[Forecast Month]
),
"Tenant Lease Executed Formatted", FORMAT(
sample_dataset[Tenant Lease Executed],
"yyyy-MM-dd HH:mm:ss"
),
"Forecast Month Formatted", FORMAT(
sample_dataset[Forecast Month],
"yyyy-MM-dd HH:mm:ss"
)
)
ORDER BY
[Tenant Lease Executed Formatted],
[Forecast Month Formatted]
- gg801 year agoFrequent Visitor
Thanks OwenAuger ! And thanks for the detailed explanation. At first I thinked was a problem in the dataset I exported from SQL Server to csv, but I checked and seems that exactly the one u described is the problem even in the original dataset. I switched the 3 fields to pure "Date" and numbers do match now.
Thanks again,
Regards!