Forum Discussion

gustavog80's avatar
gustavog80
Regular Visitor
1 year ago
Solved

Calculation groups to switch between dates not working as expected

Hi all, I'm trying to dynamize a report to give user the hability of switching between different dates to filters some data. I read some ideas and seems that the best option is set 3 relationships...
  • OwenAuger's avatar
    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]