Forum Discussion
Problems with DAX, SQL and locale
- 9 years ago
I’ve got response from the Product Team.
Based on the error message, the column 'test'[datetimes] is of data type NVARCHAR that cannot be converted to DATETIME on SQL Server side.
Unlike Import models where calculations are performed on PowerBI side, DirectQuery models push as much calculation to the underlying database as possible. In this case, the comparison operation is pushed to SQL Server and it's up to SQL Server to convert NVARCHAR to DATETIME based on its own setting.
You needs to work with your SQL Server DBA to find out the string format of the column and how to extract DATETIME values from it. As a general advice, you should work with your DBA to find out if they can create a DATETIME column directly inside the SQL Server database to have the best performance since you want to filter by that column, SQL Server cannot deliver the best query performance if a filter operation needs to perform data type conversion first.
Best Regards,
Herbert
I'm guessing the error message the team was looking at here, was the one you produced during the reproduction of my problem? If so did you set your date column ('test'[datetimes]) to be NVARCHAR, or is the team just assuming this base on the error message?
I'm asking because I posted a screenshot of the column types on the database I'm connected to, where you can without a doubt see that the date column is defined with the date data type.
Further tests I've done have involved publishing the report with a live query to the DB via a Data Gateway on the SQL Server, and then opening it with a browser on the same machine as where I use PBID. No problem at all, everything works. The problem only persists in PBID.
So in order to make sure this doesn't have anything to do with me using a 'date' column instead of a 'datetime' column I've transported all the data from DimBudget to a test database on the same server, where I now have the following columns:
Extract/Load Script (FYI):
SET NOCOUNT ON;
DECLARE @date date, @datetime datetime, @money money;
DECLARE test_cursor CURSOR
FOR
SELECT [TimeAltKey] as [date],CONVERT(datetime,[TimeAltKey],101) as [datetime] ,[BudgetTarget] as [money]
FROM [PeanutsY].[dbo].[DimBudget]
ORDER BY [TimeAltKey]
OPEN test_cursor
FETCH NEXT FROM test_cursor
INTO @date, @datetime, @money
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO TestDB.dbo.test VALUES (@date,@datetime,@money)
FETCH NEXT FROM test_cursor
INTO @date, @datetime, @money
END
CLOSE test_cursor
DEALLOCATE test_cursor
Then I create a brand new PBIX, connect it directly to the new database, load the table, edit the 'date' and 'datetime' column using locale (American English), and create my measures:
I am the DBA, as well as the BI Admin, the storage admin, the server admin and whatever else admin role exists; I do everything. There is no one for me to talk to but myself, and if I did heads would explode :D
EDIT: I assumed the last reply was from Dale, but I see now that it was from Herbert.
- v-jiascu-msft9 years agoMicrosoft Employee
- v-haibl-msft9 years agoMicrosoft Employee
- apollnor9 years agoAdvocate II
Thanks guys :)
- cxtale9 years agoRegular Visitor
I still have this issue with a time slice and I'm on Version: 2.49.4831.521 64-bit (August 2017) ???