The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
I have imported some date-times from SQL Server e.g.
2016-12-07 00:00:00.000
2016-06-08 00:00:00.000
2016-01-20 00:00:00.000
The import works fine and in Power BI Desktop/service I can see that the data is unmodified.
I have embedded this report into an MVC app and I pass along a filter constructed as so
[{ $schema:"http://powerbi.com/product/schema#advanced", target:{table:"ReportingClientActivityReport",column:"InvoiceDate"}, logicalOperator:"And", conditions: [{operator:"LessThanOrEqual",value:"2017-10-22 00:00:00Z"}, {operator:"GreaterThanOrEqual",value:"2017-10-16 00:00:00Z"}] }]
I put this filter into an embedded iframe and then pass it along to Power BI and at some point power BI has seen fit to translate my filter to UTC+10 (I get 2017-10-22 10:00:00Z and 2017-10-16 10:00:00Z) This is most likely because the server that's embedding the report is in Brisbane (UTC+10)
Is there a way I can get power BI to recognise my date-time as having already been translated to timezone?
Solved! Go to Solution.
@speedyspeedstar wrote:
My data is imported from SQL with date/time data i.e.
2016-12-07 00:00:00.000
2016-06-08 00:00:00.000
2016-01-20 00:00:00.000
and Power BI Desktop and service interprets this correctly.
I embed the report into an MVC application application and I construct this filter :
[ {$schema:"http://powerbi.com/product/schema#advanced", target {table:"ReportingClientActivityReport",column:"InvoiceDate"}, logicalOperator:"And", conditions: [{operator:"LessThanOrEqual",value:"2017-10-22 00:00:00Z"},
{operator:"GreaterThanOrEqual",value:"2017-10-16 00:00:00Z"}]} ]I put this filter in the json object for the power BI embedded iframe but when my embedded report comes back it's filtered to UTC+10 (server is in Brisbane)
How do I communicate in the filter that I want this particular DateTime without offset
The datetime format trailed with "Z" indicates a UTC format, based on my test, to get the server local datetime, you just remove the trailing "Z".
[ {$schema:"http://powerbi.com/product/schema#advanced", target {table:"ReportingClientActivityReport",column:"InvoiceDate"}, logicalOperator:"And", conditions: [{operator:"LessThanOrEqual",value:"2017-10-22 00:00:00"}, {operator:"GreaterThanOrEqual",value:"2017-10-16 00:00:00"}]} ]
See my test without VS with trailing "Z"
[Removed duplicate post]
@speedyspeedstar wrote:
My data is imported from SQL with date/time data i.e.
2016-12-07 00:00:00.000
2016-06-08 00:00:00.000
2016-01-20 00:00:00.000
and Power BI Desktop and service interprets this correctly.
I embed the report into an MVC application application and I construct this filter :
[ {$schema:"http://powerbi.com/product/schema#advanced", target {table:"ReportingClientActivityReport",column:"InvoiceDate"}, logicalOperator:"And", conditions: [{operator:"LessThanOrEqual",value:"2017-10-22 00:00:00Z"},
{operator:"GreaterThanOrEqual",value:"2017-10-16 00:00:00Z"}]} ]I put this filter in the json object for the power BI embedded iframe but when my embedded report comes back it's filtered to UTC+10 (server is in Brisbane)
How do I communicate in the filter that I want this particular DateTime without offset
The datetime format trailed with "Z" indicates a UTC format, based on my test, to get the server local datetime, you just remove the trailing "Z".
[ {$schema:"http://powerbi.com/product/schema#advanced", target {table:"ReportingClientActivityReport",column:"InvoiceDate"}, logicalOperator:"And", conditions: [{operator:"LessThanOrEqual",value:"2017-10-22 00:00:00"}, {operator:"GreaterThanOrEqual",value:"2017-10-16 00:00:00"}]} ]
See my test without VS with trailing "Z"
Awesome I'll give it a go tomorrow and let you know how it goes 🙂
edit : Works great! For C# devs with the same problem, you can use
public static string ToPowerBIDate(this DateTime src)
{
return src.ToString("s");
}
as an extension method to get local time, if you want UTC then just transform src with ToUniversalTime() and then ToString("u")