Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
speedyspeedstar
Regular Visitor

Power BI Embedded DateTime Json filter translates to UTC+10

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?

1 ACCEPTED 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


@speedyspeedstar

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"

Capture.PNG

View solution in original post

3 REPLIES 3
speedyspeedstar
Regular Visitor

[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


@speedyspeedstar

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"

Capture.PNG

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")

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.