Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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)
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
104 | |
98 | |
97 | |
38 | |
38 |
User | Count |
---|---|
153 | |
122 | |
76 | |
73 | |
66 |