Forum Discussion
Power BI Embedded DateTime Json filter translates to UTC+10
- 8 years ago
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.000and 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"
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")