March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Dear Power BI Representative,
I have a dateset where the date key was stored as date however for an incremental refresh the format needs to be set to date/time. When I try to change the type of the field to date/time I receive an error message indicating 'Unable to confirm if the M query can be folded. It is not recommended to use incremental refresh with non-foldable queries' since you cannot use a change data type when invoking an incremental refresh. Therefore how do I convert a date key to datetime without doing a change type query? Does anyone know the function for converting a date field to datetime in M code in order to invoke a function? This differs from converting an integer to date/time. Here the date is set to date and I need to convert it to date/time. The images below illustrate the error when trying to change the type on the date key. Please advise.
Thank you.
Solved! Go to Solution.
Hi @lt79_Pax ,
The data type of the RangeStart and RangeEnd parameters must be of date/time data type. However, for many data sources, tables don't have a column of date/time data type but instead have a date column of integer surrogate keys in the form of yyyymmdd
. You can create a function that converts the date/time value in the parameters to match the integer surrogate key of the data source table. The function is then called in a filter step. This step is required if the data source table contains only a surrogate key as integer data type.
Best Regards,
Jay
Hi @lt79_Pax ,
The data type of the RangeStart and RangeEnd parameters must be of date/time data type. However, for many data sources, tables don't have a column of date/time data type but instead have a date column of integer surrogate keys in the form of yyyymmdd
. You can create a function that converts the date/time value in the parameters to match the integer surrogate key of the data source table. The function is then called in a filter step. This step is required if the data source table contains only a surrogate key as integer data type.
Best Regards,
Jay
Hi AlexisOlson,
Thank you for the function however I am not familiar with M code. How would I use this function for the converting a field in preparation for an incremental refresh? If my column field name was InvoiceDate set as a date. How would this function look? DateTime.From(InvoiceDate)? When I use this I receive an error message. It also created a change type which will not work with an incremental refresh. Therefore, how would I use this function? What would be the syntax if the field InvoiceDate is of type date and I need to convert it to date/time without creating a column but invoking a function. = (x as date)=>Datetime.from(x). If I try this I also get another error message. I am afraid I just do not understand how this function can be used. Please advise.
Thank you.
Note that M is case-sensitive. That is, "DateTime.From" is not the same as "datetime.from" and the latter won't work.
It may work better for you to go the other way and convert RangeStart and RangeEnd to date type in your filter step. Try this step instead of transforming your column.
[Invoice Date Key] > Date.From(RangeStart) and [Invoice Date Key] <= Date.From(RangeEnd)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |